[Checkins] SVN: five.localsitemanager/branches/icemac-absolute-path-components/ update path in registry when reregistering after moving a registered component
Michael Howitz
mh at gocept.com
Tue Aug 26 11:17:03 EDT 2008
Log message for revision 90339:
update path in registry when reregistering after moving a registered component
Changed:
U five.localsitemanager/branches/icemac-absolute-path-components/CHANGES.txt
U five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/localsitemanager.txt
U five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/registry.py
-=-
Modified: five.localsitemanager/branches/icemac-absolute-path-components/CHANGES.txt
===================================================================
--- five.localsitemanager/branches/icemac-absolute-path-components/CHANGES.txt 2008-08-26 15:12:06 UTC (rev 90338)
+++ five.localsitemanager/branches/icemac-absolute-path-components/CHANGES.txt 2008-08-26 15:17:01 UTC (rev 90339)
@@ -15,7 +15,13 @@
context. To restore the previous behavior, register utilities
unwrapped (aq_base).
+ For storing path information the component must implement
+ getPhysicalPath and have an absolute path.
+ When a component registered as utility is moved and registered again
+ the path stored in registry gets updated.
+
+
0.4 - 2008-07-23
----------------
Modified: five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/localsitemanager.txt
===================================================================
--- five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/localsitemanager.txt 2008-08-26 15:12:06 UTC (rev 90338)
+++ five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/localsitemanager.txt 2008-08-26 15:17:01 UTC (rev 90339)
@@ -265,16 +265,21 @@
>>> zope.component.getUtility(ITestUtility, name='with_aq_chain')
<SITestUtility at /a/b/si_util>
-If we try to register a component with absolute path using another
-path, it does not get reregistered again, so getUtility returns the
-utility using the previously registered path:
+If we move a registered component (which has an absolute path) to new
+place, the registration gets updated after calling registerUtility
+again:
+ >>> ignored = self.app.a.b._setObject('c', Folder('c'))
+ >>> si_util = self.app.a.b.si_util.aq_base
+ >>> self.app.a.b._delObject('si_util')
+ >>> si_util.id = 'si_util_cped'
+ >>> ignored = self.app.a.b.c._setObject('si_util_cped', si_util)
>>> sitemanager_a.registerUtility(
- ... self.app.a.b.si_util.aq_base.__of__(self.app.a),
+ ... self.app.a.b.c.si_util_cped,
... name=u'with_aq_chain',
... provided=ITestUtility)
>>> zope.component.getUtility(ITestUtility, name='with_aq_chain')
- <SITestUtility at /a/b/si_util>
+ <SITestUtility at /a/b/c/si_util_cped>
And just to mix things up a bit. Getting back multiple utilities
should allow us to test aq, non-aq based components and components
@@ -310,7 +315,7 @@
2
>>> aqutils
[(u'aq_wrapped', <Utility AQTestUtility "test">),
- (u'with_aq_chain', <SITestUtility at /a/b/si_util>)]
+ (u'with_aq_chain', <SITestUtility at /a/b/c/si_util_cped>)]
And then getAllUtilitiesRegisteredFor():
@@ -330,7 +335,7 @@
>>> len(aqutils)
2
>>> aqutils
- [<SITestUtility at /a/b/si_util>, <Utility AQTestUtility "test">]
+ [<SITestUtility at /a/b/c/si_util_cped>, <Utility AQTestUtility "test">]
And registeredUtilities():
@@ -349,7 +354,7 @@
>>> len(aqutils)
2
>>> aqutils
- [<SITestUtility at /a/b/si_util>, <Utility AQTestUtility "test">]
+ [<SITestUtility at /a/b/c/si_util_cped>, <Utility AQTestUtility "test">]
Nested Sites
------------
Modified: five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/registry.py
===================================================================
--- five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/registry.py 2008-08-26 15:12:06 UTC (rev 90338)
+++ five.localsitemanager/branches/icemac-absolute-path-components/src/five/localsitemanager/registry.py 2008-08-26 15:17:01 UTC (rev 90339)
@@ -200,9 +200,14 @@
if provided is None:
provided = _getUtilityProvided(component)
- if (self._utility_registrations.get((provided, name))
- == (component, info)):
+ registration = self._utility_registrations.get((provided, name))
+ if (registration == (component, info)):
# already registered
+ if isinstance(registration[0], ComponentPathWrapper):
+ self.utilities.unsubscribe((), provided, registration[0])
+ # update path
+ registration[0].path = component.getPhysicalPath()
+ self.utilities.subscribe((), provided, registration[0])
return
subscribed = False
More information about the Checkins
mailing list