[Trac-tickets] [The Trac Project] #2721: !SingletonExtensionPoint

The Trac Project noreply at edgewall.com
Fri Feb 3 18:51:21 CST 2006


#2721: !SingletonExtensionPoint
-------------------------+--------------------------------------------------
 Reporter:  athomas      |       Owner:  mgood
     Type:  enhancement  |      Status:  new  
 Priority:  normal       |   Milestone:  0.10 
Component:  general      |     Version:  devel
 Severity:  normal       |    Keywords:       
-------------------------+--------------------------------------------------
 I think it would be more consistent if the ''default'' implementation
 argument of !SingletonExtensionPoint were returned as an insantiated
 component.

 ergo this patch:
 {{{
 #!diff
 Index: trac/core.py
 ===================================================================
 --- trac/core.py        (revision 2868)
 +++ trac/core.py        (working copy)
 @@ -65,7 +65,7 @@
              if impl.__class__.__name__ == cfgvalue:
                  return impl
          if self.default is not None:
 -            return self.default
 +            return self.default(component.env)
          raise AttributeError('Cannot find an implementation of the "%s" '
                               'interface named "%s".  Please update your '
                               'trac.ini setting "%s.%s"'
 }}}

 Which would, of course, be used like this:

 {{{
 #!python
     workflow = SingletonExtensionPoint(ITicketWorkflow, 'ticket',
 'workflow',
                                        DefaultTicketWorkflow)
 ...

     workflow = TicketSystem(self.env).workflow

 # as opposed to this

     workflow = TicketSystem(self.env).workflow(self.env)
 }}}

 A minor nit.

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/2721>
The Trac Project <http://trac.edgewall.com/>


More information about the Trac-Tickets mailing list