Hi,
On Fri, Jan 20, 2012 at 00:44, Olemis Lang <[email protected]> wrote:
> I'm writing a patch containing a unit test with a simplified scenario
> illustrating the barely minimal context for this to happen . The root
> cause for infinite loop is that after r10295 instances are registered
> in ComponentManager's «pool» after calling __init__ method (#9418
> records the whole discussion ;)
I can reproduce the issue and understand the condition. During a
component is initializing, accessing extension points of the component
causes infinite loop.
Solution 1.
Detect and refuse accessing the extension points during initializing
at `ExtensionPoint.extensions`.
diff --git a/trac/core.py b/trac/core.py
index 7c03577..e3594bf 100644
--- a/trac/core.py
+++ b/trac/core.py
@@ -75,6 +75,11 @@ class ExtensionPoint(property):
extension point interface.
"""
classes = ComponentMeta._registry.get(self.interface, ())
+ for cls in classes:
+ if cls not in component.compmgr and isinstance(component, cls):
+ raise RuntimeError('Cannot access extension points of the '
+ 'component during a component is '
+ 'initializing')
components = [component.compmgr[cls] for cls in classes]
return [c for c in components if c]
Solution 2.
When detecting accessing the extension points, use `component` variable
instead of `component.compmgr[cls]` at `ExtensionPoint.extensions`.
diff --git a/trac/core.py b/trac/core.py
index 7c03577..13a355d 100644
--- a/trac/core.py
+++ b/trac/core.py
@@ -75,7 +75,11 @@ class ExtensionPoint(property):
extension point interface.
"""
classes = ComponentMeta._registry.get(self.interface, ())
- components = [component.compmgr[cls] for cls in classes]
+ compmgr = component.compmgr
+ components = [component \
+ if cls not in compmgr and isinstance(component, cls) \
+ else compmgr[cls] \
+ for cls in classes]
return [c for c in components if c]
def __repr__(self):
Thoughts?
--
Jun Omae <[email protected]> (大前 潤)
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en.