> Like I said in a message sent to [email protected] (<=
> citation missing) if I had to choose among an architecture that would
> have to be changed every time a new event type is needed and another
> more stable in time I'd rather choose the later . Practicality beats
> purity . There are no such things like aspects in Trac .
Adding new methods does not mean architecture changing. IMO, practical
approach is leveraging infrastructure for repeatable work (events
dispatching in out case) and allowing plugins to concentrate on
business logic. For example, let's assume a component that listens to
changed events for Ticket and Version entities. In more generic
approach the code could look like:
{{{
class MultipleEntitiesEventsConsumer(Component):
implements(IEventListener)
#components some how define that it wants receive change events for
Ticket and Version
def event(event_name, entity, event_args):
if event_name == "created":
if isinstance(Ticket, entity):
self.ticket_created(entity, event_args["context"])
if isinstance(Version, entity):
self.version_created(entity, event_args["context"])
elif event_name == "changed":
...
#you've got the point
def ticket_created(self, entity, context):
pass
def version_created(self, entity, context):
pass
}}}
Compare this with alternative:
{{{
class MultipleEntitiesEventsConsumer(Component):
implements(IVersionPostChangeListener, TicketPostChangeListener)
def ticket_created(self, entity, context):
pass
# other "ticket_" prefixed ChangeListener methods
def version_created(self, entity, context):
pass
# other "version_" prefixed ChangeListener methods
}}}
Inspired by this discussion, I prepared a bit different proposal that
leverages ComponentManager for event dispatching and tries to solve
the problem with manual creation and maintenance of several (at least
11) I*ChangeListener interfaces per each entity:
http://trac.edgewall.org/ticket/11148#comment:2
I think the alternative proposal solves previously discussed requirements.
What do you think?
Cheers, Andrej
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.