[Checkins] SVN: zope.component/trunk/src/zope/component/ Don't
change persistent objects,
as we would need a migration step for it. The global registry usually
contains more objects,
so here the change makes much more of a difference.
Hanno Schlichting
plone at hannosch.info
Thu Nov 1 10:24:28 EDT 2007
Log message for revision 81357:
Don't change persistent objects, as we would need a migration step for it. The global registry usually contains more objects, so here the change makes much more of a difference.
Changed:
U zope.component/trunk/src/zope/component/persistentregistry.py
U zope.component/trunk/src/zope/component/registry.py
-=-
Modified: zope.component/trunk/src/zope/component/persistentregistry.py
===================================================================
--- zope.component/trunk/src/zope/component/persistentregistry.py 2007-11-01 12:58:47 UTC (rev 81356)
+++ zope.component/trunk/src/zope/component/persistentregistry.py 2007-11-01 14:24:27 UTC (rev 81357)
@@ -51,7 +51,6 @@
def _init_registrations(self):
self._utility_registrations = persistent.mapping.PersistentMapping()
- self._utility_subscribers = persistent.mapping.PersistentMapping()
self._adapter_registrations = persistent.mapping.PersistentMapping()
self._subscription_registrations = persistent.list.PersistentList()
self._handler_registrations = persistent.list.PersistentList()
Modified: zope.component/trunk/src/zope/component/registry.py
===================================================================
--- zope.component/trunk/src/zope/component/registry.py 2007-11-01 12:58:47 UTC (rev 81356)
+++ zope.component/trunk/src/zope/component/registry.py 2007-11-01 14:24:27 UTC (rev 81357)
@@ -76,9 +76,19 @@
# already registered
return
- subscribed = self._utility_subscribers.get((provided, component), False)
+ subscribed = False
+ if hasattr(self, '_utility_subscribers'):
+ subscribed = self._utility_subscribers.get((provided, component),
+ False)
+ else:
+ for ((p, _), (c,_)) in self._utility_registrations.iteritems():
+ if p == provided and c == component:
+ subscribed = True
+ break
+
self._utility_registrations[(provided, name)] = component, info
- self._utility_subscribers[(provided, component)] = True
+ if hasattr(self, '_utility_subscribers'):
+ self._utility_subscribers[(provided, component)] = True
self.utilities.register((), provided, name, component)
if not subscribed:
@@ -105,8 +115,17 @@
del self._utility_registrations[(provided, name)]
self.utilities.unregister((), provided, name)
- subscribed = self._utility_subscribers.get((provided, component), False)
- del self._utility_subscribers[(provided, component)]
+ subscribed = False
+ if hasattr(self, '_utility_subscribers'):
+ subscribed = self._utility_subscribers.get((provided, component),
+ False)
+ del self._utility_subscribers[(provided, component)]
+ else:
+ for ((p, _), (c,_)) in self._utility_registrations.iteritems():
+ if p == provided and c == component:
+ subscribed = True
+ break
+
if not subscribed:
self.utilities.unsubscribe((), provided, component)
More information about the Checkins
mailing list