[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/app/component/
Fixed some deprecation problems and changed deprecated registries to
Jim Fulton
jim at zope.com
Mon Apr 24 07:15:09 EDT 2006
Log message for revision 67564:
Fixed some deprecation problems and changed deprecated registries to
be aliases to new local registry.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/component/adapter.py
U Zope3/branches/jim-adapter/src/zope/app/component/back35.py
U Zope3/branches/jim-adapter/src/zope/app/component/site.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/component/adapter.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/adapter.py 2006-04-24 10:36:19 UTC (rev 67563)
+++ Zope3/branches/jim-adapter/src/zope/app/component/adapter.py 2006-04-24 11:15:08 UTC (rev 67564)
@@ -19,7 +19,7 @@
"Local registration is now much simpler. The old baroque APIs "
"will go away in Zope 3.5. See the new component-registration APIs "
"defined in zope.component, especially IComponentRegistry.",
- LocalAdapterRegistry = 'zope.app.component.back35.AdapterRegistry',
- AdapterRegistration = 'zope.app.component.back35.AdapterRegistration2',
+ LocalAdapterRegistry = 'zope.app.component.site:_LocalAdapterRegistry',
+ AdapterRegistration = 'zope.app.component.back35:AdapterRegistration2',
)
Modified: Zope3/branches/jim-adapter/src/zope/app/component/back35.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/back35.py 2006-04-24 10:36:19 UTC (rev 67563)
+++ Zope3/branches/jim-adapter/src/zope/app/component/back35.py 2006-04-24 11:15:08 UTC (rev 67564)
@@ -633,76 +633,6 @@
def getRegistry(self):
return zapi.getSiteManager(self)
-class LocalAdapterRegistry(zope.interface.adapter.AdapterRegistry,
- Persistent):
- """Local/persistent surrogate registry"""
- interface.implements(ILocalAdapterRegistry)
-
- # See interfaces.registration.ILocatedRegistry
- next = None
- subs = ()
-
- def __init__(self, base, next=None):
- # Base registry. This is always a global registry
- self.base = base
- # `adapters` is simple dict, since it is populated during every load
- self.adapters = {}
- self._registrations = ()
- super(LocalAdapterRegistry, self).__init__()
- self.setNext(next)
-
- def addSub(self, sub):
- self.subs += (sub, )
-
- def removeSub(self, sub):
- self.subs = tuple(
- [s for s in self.subs if s is not sub] )
-
- def setNext(self, next, base=None):
- if base is not None:
- self.base = base
-
- if next != self.next:
- if self.next is not None:
- self.next.removeSub(self)
- if next is not None:
- next.addSub(self)
- self.next = next
-
- self.__bases__ = tuple([b for b in (next, self.base) if b is not None])
-
- for sub in self.subs:
- sub.setNext(self)
-
-
- def register(self, registration):
- self._registrations += (registration,)
-
- zope.interface.adapter.AdapterRegistry.register(
- self,
- (registration.required, ) + registration.with,
- registration.provided, registration.name,
- registration.component,
- )
-
- def unregister(self, registration):
- self._registrations = tuple([reg for reg in self._registrations
- if reg is not registration])
-
- zope.interface.adapter.AdapterRegistry.unregister(
- self,
- (registration.required, ) + registration.with,
- registration.provided, registration.name,
- registration.component,
- )
-
- def registered(self, registration):
- return registration in self._registrations
-
- def registrations(self):
- """See zope.app.component.interfaces.registration.IRegistry"""
- return self._registrations
-
class AdapterRegistration2(ComponentRegistration):
"""A simple implementation of the adapter registration interface."""
interface.implements(IAdapterRegistration)
@@ -734,67 +664,6 @@
'permission=%r' %self.permission +
'>')
-class LocalUtilityRegistry(LocalAdapterRegistry):
-
- zope.deprecation.deprecate(
- "Will go away in Zope 3.5. Use registerUtility instead."
- )
- def register(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- self._registrations += (registration,)
-
- zope.interface.adapter.AdapterRegistry.register(
- self,
- (),
- registration.provided, registration.name,
- registration.component,
- )
-
- # XXX need test that this second part happens
- zope.interface.adapter.AdapterRegistry.subscribe(
- self,
- (),
- registration.provided,
- registration.component,
- )
-
- zope.deprecation.deprecate(
- "Will go away in Zope 3.5. Use unregisterUtility instead."
- )
- def unregister(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- self._registrations = tuple([reg for reg in self._registrations
- if reg is not registration])
-
- zope.interface.adapter.AdapterRegistry.unregister(
- self,
- (),
- registration.provided, registration.name,
- registration.component,
- )
-
-
- # XXX need test that this second part happens
- zope.interface.adapter.AdapterRegistry.unsubscribe(
- self,
- (),
- registration.provided,
- registration.component,
- )
-
- zope.deprecation.deprecate(
- "Will go away in Zope 3.5. "
- "Use registeredUtilities on site manager instead."
- )
- @zope.deprecation.deprecate("Will go away in Zope 3.5")
- def registered(self, registration):
- raise TypeError("We never supported adapters")
-
- @zope.deprecation.deprecate("Will go away in Zope 3.5")
- def registrations(self):
- raise TypeError("We never supported adapters")
-
-
class UtilityRegistration(ComponentRegistration):
"""Utility component registration for persistent components
Modified: Zope3/branches/jim-adapter/src/zope/app/component/site.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/site.py 2006-04-24 10:36:19 UTC (rev 67563)
+++ Zope3/branches/jim-adapter/src/zope/app/component/site.py 2006-04-24 11:15:08 UTC (rev 67564)
@@ -137,7 +137,6 @@
return site.getSiteManager()
-
class _LocalAdapterRegistry(
zope.component.persistentregistry.PersistentAdapterRegistry,
zope.location.Location,
@@ -354,13 +353,12 @@
for r in self.registeredSubscriptionAdapters():
yield r
-zope.deferredimport.deprecatedFrom(
+zope.deferredimport.deprecated(
"Local registration is now much simpler. The old baroque APIs "
"will go away in Zope 3.5. See the new component-registration APIs "
"defined in zope.component, especially IComponentRegistry.",
- 'zope.app.component.back35',
- 'LocalAdapterRegistry', 'AdapterRegistration',
- 'LocalUtilityRegistry', 'UtilityRegistration',
+ LocalAdapterRegistry = 'zope.app.component.site:_LocalAdapterRegistry',
+ LocalUtilityRegistry = 'zope.app.component.site:_LocalAdapterRegistry',
)
def threadSiteSubscriber(ob, event):
More information about the Zope3-Checkins
mailing list