Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#2721 closed defect (fixed)

SingletonExtensionPoint should return instantiated Component?

Reported by: Alec Thomas Owned by: Matthew Good
Priority: normal Milestone: 0.10
Component: general Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

I think it would be more consistent if the default implementation argument of SingletonExtensionPoint were returned as an insantiated component.

ergo this patch:

  • trac/core.py

     
    6565            if impl.__class__.__name__ == cfgvalue:
    6666                return impl
    6767        if self.default is not None:
    68             return self.default
     68            return self.default(component.env)
    6969        raise AttributeError('Cannot find an implementation of the "%s" '
    7070                             'interface named "%s".  Please update your '
    7171                             'trac.ini setting "%s.%s"'

Which would, of course, be used like this:

    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.

Attachments (0)

Change History (2)

comment:1 by Alec Thomas, 18 years ago

Summary: !SingletonExtensionPointSingletonExtensionPoint should return instantiated Component?

comment:2 by Matthew Good, 18 years ago

Resolution: fixed
Status: newclosed
Type: enhancementdefect

Actually I would consider that a defect since the return type is inconsistent.

Anyways, fixed in [2939].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Matthew Good.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Matthew Good to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.