Opened 15 months ago
Remove frame hack for ticket_created
|Reported by:||ejucovy||Owned by:||ejucovy|
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)