Modify

Opened 6 months ago

#10691 new task

Remove frame hack for ticket_created

Reported by: ejucovy Owned by: ejucovy
Priority: low Component: WorkflowNotificationPlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

Currently the plugin has to use a Python frame hack in the ticket_created method:

    def ticket_created(self, ticket):
        req = None

        for frame, __, ___, ____, _____, ______ in inspect.getouterframes(inspect.currentframe())[1:]:
            if 'req' in frame.f_locals:
                req = frame.f_locals['req']
                break
        if req is None:
            return

        self.apply_action_side_effects(req, ticket, '@created')

This is because Trac's ITicketChangeListener.ticket_created method does not receive a request, which we need to generate meaningful notifications. (We need the request to find the change's author and comment, if any.) But the method isn't sent a request because tickets may be created outside the context of an HTTP request.

It would be nice to be able to get rid of this frame hack -- either by figuring out another, more appropriate hook to plug in to, or by requesting a change in Trac's API here (perhaps ticket_created(ticket, req=None); or perhaps by an extension to ITicketActionController)

Attachments (0)

Change History (0)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from ejucovy. Next status will be 'new'.
The owner will be changed from ejucovy to anonymous. Next status will be 'assigned'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.