Hi all,

TLDR: ITicketManipulator.validate_ticket() supplies a req parameter, 
ITicketChanged.ticket_changed() doesn't. Is this an intentional design 
decision, or would patch that adds an optional req parameter be considered for 
inclusion with Trac?

I'm currently finishing the remote ticket plugin I started long ago. The plugin 
will eventually allow a ticket to be linked to another ticket in another 
project - provided it's run using the ticketlinks branch of Trac.

In the plugin I am using ITicketChanged interface as a trigger to RPC update of 
the tickets in other projects. To authenticate to the other projects it's very 
useful to have a req instance - which the ticket_created()/ticket_changed() 
methods don't currently supply. For now I'm performing a horrid hack in 
ticket_validate() - saving a reference to req as an attribute on the Ticket 
instance.

Is there a better way to achieve my goal: when a ticket changes locally, 
attempt to update remote linked ticket to match - reusing any authentication 
tokens that we included with the request. Otherwise, do you think extending 
ITicketChanged (to optionally provide req) would make a sensible evolution of 
Trac? Or is that a horrid architecture violation?

I'm thinking the signature could become ticket_changed(self, ticket, comment, 
author, old_values, req=None) or ticket_changed(self, req, ticket, comment, 
author, old_values) with an arity() check like post_process_request().

The plugin code I'm currently using looks like:

class RemoteLinksProvider(Component):
    """Validate and save remote ticket links when a ticket is modified.
    """
    implements(ITicketChangeListener,
    # ITicketChangeListener methods
    def ticket_created(self, ticket):
        self.ticket_changed(ticket, '', ticket['reporter'], None)

    def ticket_changed(self, ticket, comment, author, old_values):
        ....
        # Push changes to remote sites
        req = ticket._evil_remote_ticket_hack
        self._update_remote_sites(ticket, req)

    # ITicketManipulator methods
    def prepare_ticket(self, req, ticket, fields, actions):
        pass

    def validate_ticket(self, req, ticket):
        ....
        # Evil hack alert! Need a way to authenticate to any remote hosts, if
        # there are changes to the remote ticket links. However once we reach
        # ITicketChangeListener ticket_changed() Trac doesn't provide the
        # request object
        ticket._evil_remote_ticket_hack = req

Regards, Alex
--
Alex Willmer | Developer
2 Trinity Park,  Birmingham, B37 7ES | United Kingdom
M: +44 7557 752744
[email protected]<mailto:[email protected]> | www.logica.com
<http://www.logica.com/>Logica UK Ltd, registered in UK (registered number 
947968)
Registered Office: 250 Brook Drive, Green Park, Reading RG2 6UA, United Kingdom



Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-users?hl=en.

Reply via email to