Edgewall Software

Changes between Version 16 and Version 17 of TracDev/ComponentArchitecture


Ignore:
Timestamp:
Nov 19, 2010, 5:50:25 PM (14 years ago)
Author:
Remy Blank
Comment:

Clarified the section about component instantiation.

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/ComponentArchitecture

    v16 v17  
    120120The `TodoList` component notifies the observers inside the `add()` method by iterating over `self.observers` and calling the `todo_added()` method for each. This works because the `observers` attribute is a [http://users.rcn.com/python/download/Descriptor.htm descriptor]: When it is accessed, it finds all registered components that declare to extend the extension point. For each of those components, it gets the instance from the component manager, potentially activating it if it is getting accessed for the first time.
    121121
    122 '''Note:''' Components are registered when they're created/used for the first time. There are two ways to initiate a component: either call `ComponentName(self.compmgr)` or list it in the [wiki:TracIni trac.ini] `[components]` section. However, the former way may result in the component not being listed in the extension points (`self.observers` in the example above). It's currently discussed whether this is a bug or working as intended (see #9851).
     122'''Note:''' Component classes are registered at module load time. A specific component is instantiated on first use, either when accessing an extension point for an interface implemented by that component, or when calling the component constructor as `ComponentName(self.compmgr)`. The former use requires the component to be enabled in the `[components]` section of [wiki:TracIni trac.ini], while in the latter use the component will be instantiated regardless. Note that in this last case, even though the component is instantiated, it's only made available through the extension points if it's enabled in `[components]`.
    123123
    124124== Plugging in to an extension point ==