Edgewall Software

Changes between Version 6 and Version 7 of TracPluggableModules

Nov 20, 2004, 11:59:50 AM (18 years ago)

Contribute idea: link to TracObjectModelProposal , module configurability and Client interfaces


  • TracPluggableModules

    v6 v7  
    6969 * contribute functionality to other modules
    7070 * provide hooks so that other modules can contribute to its functionality
     72=== By using Function Hooks ===
    7274The supporting model for such cooperation between modules should be functions defined by the contributing plug-in, and called by the plug-in to which we contribute. For example, let's assume the timeline module documents the following hook functions (or ''extension points'' in Eclipse jargon):
    102104This is probably just the price to pay for a cleaner architecture, but optimizations may be possible.
     106=== By using ExtensionPoint Interfaces ===
     108Alternatively, a Module could define one or
     109several client interfaces (all ExtensionPoint
     110subclasses), and the other modules could provide zero,
     111one or more implementations for this Client interface.
     113This approach would provide both clarity and flexibility
     114(if not even a simpler programming model) than the
     115''hook functions'' approach.
     117See a more detailed description below
     118'''Your Ideas Wanted / Modules and Configurability'''
    104121== Other Aspects of Plug-Ins ==
     134=== Trac Modules and Trac Objects ===
     136The approach of Pluggable Module described here
     137would be complementary to the Trac Objects idea
     138described here: TracObjectModelProposal.
     142=== Modules and Configurability ===
     144In some cases, one would like to have a fine control
     145on how a module works. I'll take an example.
     146The Timeline module interacts with the Ticket module.
     147The latter provide several timeline entries to be
     148displayed by the former, as well as specific filters
     149for composing the filter panel.
     151But let's say I would be interested in having
     152the Ticket Contributions displayed (See #187 and my
     153patch at #890), whereas others wouldn't want this
     154option to be available. How to solve this?
     155 * Subclassing the Ticket module?
     156   (For the ''hook function approach'': not very
     157   flexible, what if there are multiple optional
     158   features)
     159 * A configuration flag for the Ticket module?
     160   (This would be more flexible, but, well, would be
     161   spaghetti code in the end!)
     162 * Have the Ticket module provide a (configurable) list
     163   of !TimelineEventProvider objects (the, or one of the
     164   ExtensionPoint interface that the Timeline module
     165   would offer)?
     167The last idea seems the most interesting.
     168The Timeline module expects that the
     169other modules will provide zero or more
     170!TimelineEventProvider object.
     172The Ticket module would implement all of the following subclasses of !TimelineEventProvider class:
     173 * !NewAndCloseTicketsInTimeline
     174 * !ReopenedTicketsInTimeline
     175 * !TicketContributionsInTimeline
     177After being configured (either from the {{{trac.ini}}}
     178file, or any other mean, even dynamically!),
     179the Ticket module could decide which instances of
     180these subclasses will be given to the Timeline instance.
     182The !TimelineEventProvider and ExtensionPoint could be
     183defined as:
     186class ExtensionPoint:
     187    def module(self):
     188        """The module providing this client for the timeline"""
     189        pass
     190    ...
     192class TimelineEventProvider(ExtensionPoint):
     193    def query_string(self):
     194        """The SQL fragment which provides:
     195 * time: the timestamp of the event
     196 * idata: the unique identifier for this event
     197 * ... and so on
     199        pass
     201    def render_item(self,item):
     202        """Populate the item dictionary with hdf data"""
     203        pass
     204    ...