[Zope3-checkins] CVS: Zope3/src/zope/app/services - adapter.py:1.22 cache.py:1.19 connection.py:1.21 event.py:1.35 interface.py:1.17 module.py:1.15 principalannotation.py:1.10 role.py:1.7

Jim Fulton jim at zope.com
Sun Sep 21 13:32:00 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv13558/src/zope/app/services

Modified Files:
	adapter.py cache.py connection.py event.py interface.py 
	module.py principalannotation.py role.py 
Log Message:
No-longer use context wrappers.


=== Zope3/src/zope/app/services/adapter.py 1.21 => 1.22 ===
--- Zope3/src/zope/app/services/adapter.py:1.21	Mon Jun 30 12:24:38 2003
+++ Zope3/src/zope/app/services/adapter.py	Sun Sep 21 13:31:59 2003
@@ -29,11 +29,10 @@
 from zope.app.interfaces.services.registration import IRegistry
 from zope.app.services.registration import RegistrationStack
 from zope.app.services.registration import SimpleRegistration
-from zope.app.context import ContextWrapper
 from zope.app.component.nextservice import getNextService
 from zope.app.interfaces.services.service import ISimpleService
-
 from zope.app.interfaces.services.adapter import IAdapterRegistration
+from zope.app.container.contained import Contained
 
 class PersistentAdapterRegistry(Persistent, AdapterRegistry):
 
@@ -41,7 +40,7 @@
         AdapterRegistry.__init__(self, PersistentDict())
 
 
-class AdapterService(Persistent):
+class AdapterService(Persistent, Contained):
 
     implements(IAdapterService, IRegistry, ISimpleService)
 
@@ -56,8 +55,6 @@
             registration.adapterName,
             default)
 
-    queryRegistrationsFor = zapi.ContextMethod(queryRegistrationsFor)
-
     def queryRegistrations(self,
                             forInterface, providedInterface, adapterName,
                             default=None):
@@ -70,9 +67,7 @@
         if registry is None:
             return default
 
-        return ContextWrapper(registry, self)
-
-    queryRegistrations = zapi.ContextMethod(queryRegistrations)
+        return registry
 
     def createRegistrationsFor(self, registration):
         "See IRegistry"
@@ -81,8 +76,6 @@
             registration.forInterface, registration.providedInterface,
             registration.adapterName)
 
-    createRegistrationsFor = zapi.ContextMethod(createRegistrationsFor)
-
     def createRegistrations(self, forInterface, providedInterface, name):
 
         adapters = self._byName.get(name)
@@ -92,12 +85,10 @@
 
         registry = adapters.getRegistered(forInterface, providedInterface)
         if registry is None:
-            registry = RegistrationStack()
+            registry = RegistrationStack(self)
             adapters.register(forInterface, providedInterface, registry)
 
-        return ContextWrapper(registry, self)
-
-    createRegistrations = zapi.ContextMethod(createRegistrations)
+        return registry
 
     def getAdapter(self, object, interface, name=''):
         "See IAdapterService"
@@ -106,8 +97,6 @@
             raise ComponentLookupError(object, interface)
         return adapter
 
-    getAdapter = zapi.ContextMethod(getAdapter)
-
     def getNamedAdapter(self, object, interface, name):
         "See IAdapterService"
         adapter = self.queryNamedAdapter(object, interface, name)
@@ -115,8 +104,6 @@
             raise ComponentLookupError(object, interface)
         return adapter
 
-    getNamedAdapter = zapi.ContextMethod(getNamedAdapter)
-
     def queryAdapter(self, object, interface, default=None, name=''):
         """see IAdapterService interface"""
         if name:
@@ -150,20 +137,16 @@
 
         return self.queryNamedAdapter(object, interface, name, default)
 
-    queryAdapter = zapi.ContextMethod(queryAdapter)
-
     def queryNamedAdapter(self, object, interface, name, default=None):
         adapters = self._byName.get(name)
 
         if adapters:
             registry = adapters.getForObject(
                 object, interface,
-                filter = lambda registry:
-                         ContextWrapper(registry, self).active(),
+                filter = lambda registry: registry.active(),
                 )
 
             if registry is not None:
-                registry = ContextWrapper(registry, self)
                 adapter = registry.active().getAdapter(object)
                 return adapter
 
@@ -171,8 +154,6 @@
 
         return adapters.queryNamedAdapter(object, interface, name, default)
 
-    queryNamedAdapter = zapi.ContextMethod(queryNamedAdapter)
-
     # XXX need to add name support
     def getRegisteredMatching(self,
                               for_interfaces=None,
@@ -210,11 +191,9 @@
         self.factoryName = factoryName
 
     def getAdapter(self, object):
-        folder = zapi.getWrapperContainer(zapi.getWrapperContainer(self))
+        folder = self.__parent__.__parent__
         factory = folder.resolve(self.factoryName)
         return factory(object)
-
-    getAdapter = zapi.ContextMethod(getAdapter)
 
 # XXX Pickle backward compatability
 AdapterConfiguration = AdapterRegistration


=== Zope3/src/zope/app/services/cache.py 1.18 => 1.19 ===
--- Zope3/src/zope/app/services/cache.py:1.18	Tue Aug 19 19:11:05 2003
+++ Zope3/src/zope/app/services/cache.py	Sun Sep 21 13:31:59 2003
@@ -24,8 +24,9 @@
 from zope.app.services.event import ServiceSubscriberEventChannel
 from zope.app.services.servicenames import Utilities
 from zope.interface import implements
+from zope.app.container.contained import Contained
 
-class CachingService(ServiceSubscriberEventChannel, Persistent):
+class CachingService(ServiceSubscriberEventChannel, Persistent, Contained):
 
     implements(ILocalCachingService, ISimpleService)
 
@@ -38,17 +39,17 @@
         'See ICachingService'
         utilities = zapi.getService(self, Utilities)
         return utilities.getUtility(ICache, name)
-    getCache = zapi.ContextMethod(getCache)
+    
 
     def queryCache(self, name, default=None):
         'See ICachingService'
         utilities = zapi.getService(self, Utilities)
         return utilities.queryUtility(ICache, default, name)
-    queryCache = zapi.ContextMethod(queryCache)
+    
 
     def getAvailableCaches(self):
         'See ICachingService'
         utilities = zapi.getService(self, Utilities)
         caches = utilities.getUtilitiesFor(ICache)
         return map(lambda c: c[0], caches)
-    getAvailableCaches = zapi.ContextMethod(getAvailableCaches)
+    


=== Zope3/src/zope/app/services/connection.py 1.20 => 1.21 ===
--- Zope3/src/zope/app/services/connection.py:1.20	Thu Aug 21 08:01:21 2003
+++ Zope3/src/zope/app/services/connection.py	Sun Sep 21 13:31:59 2003
@@ -22,8 +22,9 @@
 from zope.app.interfaces.services.service import ISimpleService
 from zope.app.services.servicenames import Utilities
 from zope.interface import implements
+from zope.app.container.contained import Contained
 
-class ConnectionService(Persistent):
+class ConnectionService(Persistent, Contained):
     """This is a local relational database connection service."""
 
     implements(ILocalConnectionService, ISimpleService)
@@ -33,7 +34,6 @@
         utilities = zapi.getService(self, Utilities)
         dbadapter = utilities.getUtility(IZopeDatabaseAdapter, name)
         return dbadapter()
-    getConnection = zapi.ContextMethod(getConnection)
 
     def queryConnection(self, name, default=None):
         'See IConnectionService'
@@ -43,11 +43,9 @@
             return dbadapter()
         else:
             return default
-    queryConnection = zapi.ContextMethod(queryConnection)
 
     def getAvailableConnections(self):
         'See IConnectionService'
         utilities = zapi.getService(self, Utilities)
         connections = utilities.getUtilitiesFor(IZopeDatabaseAdapter)
         return map(lambda c: c[0], connections)
-    getAvailableConnections = zapi.ContextMethod(getAvailableConnections)


=== Zope3/src/zope/app/services/event.py 1.34 => 1.35 ===
--- Zope3/src/zope/app/services/event.py:1.34	Mon Jul 14 07:07:22 2003
+++ Zope3/src/zope/app/services/event.py	Sun Sep 21 13:31:59 2003
@@ -39,6 +39,7 @@
 from zope.app.event.subs import Subscribable, SubscriptionTracker
 
 from zope.security.proxy import trustedRemoveSecurityProxy
+from zope.app.container.contained import Contained
 
 import logging
 
@@ -142,7 +143,6 @@
     def notify(wrapped_self, event):
         clean_self = removeAllProxies(wrapped_self)
         clean_self._notify(wrapped_self, event)
-    notify = zapi.ContextMethod(notify)
 
 
 class ServiceSubscriberEventChannel(SubscriptionTracker, EventChannel):
@@ -170,13 +170,12 @@
     _subscribeToServiceInterface = IEvent
     _subscribeToServiceFilter = None
 
-    def subscribe(wrapped_self, reference, event_type=IEvent, filter=None):
-        if getattr(wrapped_self, "_v_ssecunbinding", None) is not None:
+    def subscribe(self, reference, event_type=IEvent, filter=None):
+        if getattr(self, "_v_ssecunbinding", None) is not None:
             raise Exception(
                 'Cannot subscribe to a subscriber that is unbinding.')
-        return zapi.ContextSuper(ServiceSubscriberEventChannel, wrapped_self
-                ).subscribe(reference, event_type, filter)
-    subscribe = zapi.ContextMethod(subscribe)
+        return super(ServiceSubscriberEventChannel, self
+                     ).subscribe(reference, event_type, filter)
 
     def bound(wrapped_self, name):
         "See IBindingAware"
@@ -205,7 +204,6 @@
                     clean_self._subscribeToServiceInterface,
                     clean_self._subscribeToServiceFilter
                     )
-    bound = zapi.ContextMethod(bound)
 
     def unbound(wrapped_self, name):
         "See IBindingAware"
@@ -253,7 +251,6 @@
         assert len(paths) == len(hubIds) == len(clean_self._registry) == 0
 
         clean_self._serviceName = None
-    unbound = zapi.ContextMethod(unbound)
 
 
 class ServiceSubscribable(Subscribable):
@@ -273,75 +270,69 @@
 
     # requires __init__ from zope.app.event.subs.Subscribable
 
-    def unsubscribe(wrapped_self, reference, event_type, filter=None):
+    def unsubscribe(self, reference, event_type, filter=None):
         # The point here is that if we can't unsubscribe here, we should
         # allow the next event service to unsubscribe.
         try:
-            zapi.ContextSuper(ServiceSubscribable, wrapped_self).unsubscribe(
-                reference, event_type, filter)
+            super(ServiceSubscribable, self
+                  ).unsubscribe(reference, event_type, filter)
         except NotFoundError:
-            next_service = queryNextService(wrapped_self,
-                                            wrapped_self._serviceName)
+            next_service = queryNextService(self,
+                                            self._serviceName)
             if next_service is not None:
                 next_service.unsubscribe(reference, event_type, filter)
             else:
                 raise
-    unsubscribe = zapi.ContextMethod(unsubscribe)
 
-    def unsubscribeAll(wrapped_self, reference, event_type=IEvent,
+    def unsubscribeAll(self, reference, event_type=IEvent,
                        local_only=False):
         # unsubscribe all from here, and from the next service
 
         # n is the number of subscriptions removed
-        n = zapi.ContextSuper(ServiceSubscribable, wrapped_self).unsubscribeAll(
-            reference, event_type)
+        n = super(ServiceSubscribable, self
+                  ).unsubscribeAll(reference, event_type)
         if not local_only:
-            next_service = queryNextService(wrapped_self,
-                                            wrapped_self._serviceName)
+            next_service = queryNextService(self, self._serviceName)
             if next_service is not None:
                 n += next_service.unsubscribeAll(reference, event_type)
         return n
-    unsubscribeAll = zapi.ContextMethod(unsubscribeAll)
 
-    def resubscribeByHubId(wrapped_self, reference):
-        n = zapi.ContextSuper(ServiceSubscribable, wrapped_self
-            ).resubscribeByHubId(reference)
-        next_service = queryNextService(wrapped_self,
-                                        wrapped_self._serviceName)
+    def resubscribeByHubId(self, reference):
+        n = super(ServiceSubscribable, self
+                  ).resubscribeByHubId(reference)
+        next_service = queryNextService(self, self._serviceName)
         if next_service is not None:
             n += next_service.resubscribeByHubId(reference)
         return n
 
-    def resubscribeByPath(wrapped_self, reference):
-        n = zapi.ContextSuper(ServiceSubscribable, wrapped_self
-            ).resubscribeByPath(reference)
-        next_service = queryNextService(wrapped_self,
-                                        wrapped_self._serviceName)
+    def resubscribeByPath(self, reference):
+        n = super(ServiceSubscribable, self
+                  ).resubscribeByPath(reference)
+        next_service = queryNextService(self, self._serviceName)
         if next_service is not None:
             n += next_service.resubscribeByPath(reference)
         return n
 
-    def iterSubscriptions(wrapped_self, reference=None, event_type=IEvent,
+    def iterSubscriptions(self, reference=None, event_type=IEvent,
                           local_only=False):
         'See ISubscriptionService'
-        subs = zapi.ContextSuper(ServiceSubscribable, wrapped_self
-                ).iterSubscriptions(reference, event_type)
+        subs = super(ServiceSubscribable, self
+                     ).iterSubscriptions(reference, event_type)
         for subscription in subs:
             yield subscription
 
         if not local_only:
-            next_service = queryNextService(wrapped_self,
-                                            wrapped_self._serviceName)
+            next_service = queryNextService(self, self._serviceName)
             if next_service is not None:
                 for subscription in next_service.iterSubscriptions(
                     reference, event_type):
                     yield subscription
-    iterSubscriptions = zapi.ContextMethod(iterSubscriptions)
 
 
 from zope.app.interfaces.services.service import ISimpleService
 
-class EventService(ServiceSubscriberEventChannel, ServiceSubscribable):
+class EventService(ServiceSubscriberEventChannel, ServiceSubscribable,
+                   Contained):
 
     implements(IEventService, ISubscriptionService, ISimpleService)
 
@@ -371,7 +362,6 @@
                 getNextService(wrapped_self, EventPublication).publish(event)
         finally:
             publishedEvents.remove(event)
-    publish = zapi.ContextMethod(publish)
 
     def notify(wrapped_self, event):
         "see ISubscriber"
@@ -379,7 +369,6 @@
         publishedEvents = getattr(clean_self, "_v_publishedEvents", [])
         if event not in publishedEvents:
             clean_self._notify(wrapped_self, event)
-    notify = zapi.ContextMethod(notify)
 
     def bound(wrapped_self, name):
         "See IBindingAware"
@@ -396,32 +385,30 @@
                     pass
                 else:
                     es.subscribe(wrapped_self)
-    bound = zapi.ContextMethod(bound)
 
-    def unbound(wrapped_self, name):
+    def unbound(self, name):
         "See IBindingAware"
         # An event service is bound as EventSubscription and EventPublication.
         # We only want to unsubscribe from the next event service when
         # we're unbound as EventSubscription
         if name == EventSubscription:
-            clean_self = removeAllProxies(wrapped_self)
+            clean_self = removeAllProxies(self)
 
             # This flag is used by the unsubscribedFrom method (below) to
             # determine that it doesn't need to further unsubscribe beyond
             # what we're already doing.
             clean_self._v_unbinding = True
             try:
-                zapi.ContextSuper(EventService, wrapped_self).unbound(name)
+                super(EventService, self).unbound(name)
             finally:
                 # unset flag
                 del clean_self._v_unbinding
-    unbound = zapi.ContextMethod(unbound)
 
-    def unsubscribedFrom(wrapped_self, subscribable, event_type, filter):
+    def unsubscribedFrom(self, subscribable, event_type, filter):
         "See ISubscribingAware"
-        zapi.ContextSuper(EventService, wrapped_self).unsubscribedFrom(
-            subscribable, event_type, filter)
-        clean_self = removeAllProxies(wrapped_self)
+        super(EventService, self
+              ).unsubscribedFrom(subscribable, event_type, filter)
+        clean_self = removeAllProxies(self)
         if getattr(clean_self, "_v_unbinding", None) is None:
             # we presumably have been unsubscribed from a higher-level
             # event service because that event service is unbinding
@@ -432,7 +419,7 @@
             if ISubscriptionService.isImplementedBy(
                 removeAllProxies(clean_subscribable)):
                 try:
-                    context = zapi.getService(wrapped_self, EventSubscription)
+                    context = zapi.getService(self, EventSubscription)
                     # we do this instead of getNextService because the order
                     # of unbinding and notification of unbinding is not
                     # guaranteed
@@ -442,6 +429,5 @@
                 except ComponentLookupError:
                     pass
                 else:
-                    context.subscribe(wrapped_self)
-    unsubscribedFrom = zapi.ContextMethod(unsubscribedFrom)
+                    context.subscribe(self)
 


=== Zope3/src/zope/app/services/interface.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/services/interface.py:1.16	Sun Aug 17 02:08:11 2003
+++ Zope3/src/zope/app/services/interface.py	Sun Sep 21 13:31:59 2003
@@ -32,6 +32,8 @@
 from zope.app.services.servicenames import Interfaces, Utilities
 from zope.component import ComponentLookupError
 from zope.interface import implements
+from zope.app.container.contained import Contained
+from zope.app.interfaces.services.registration import IRegistrationStack
 
 class PersistentInterfaceClass(Persistent, InterfaceClass):
     pass
@@ -54,14 +56,11 @@
                 )
 
 
-class LocalInterfaceService(object):
+class LocalInterfaceService(Contained):
     """A local interface service."""
 
     implements(IInterfaceService,
                ISimpleService)
-
-    # All the methods defined here are context methods
-    zapi.ContextAwareDescriptors()
 
     def getInterface(self, id):
         # Return the interface registered for the given id


=== Zope3/src/zope/app/services/module.py 1.14 => 1.15 ===
--- Zope3/src/zope/app/services/module.py:1.14	Sun Aug 17 02:08:11 2003
+++ Zope3/src/zope/app/services/module.py	Sun Sep 21 13:31:59 2003
@@ -28,13 +28,12 @@
 from zope.app.interfaces.services.module import IModuleManager
 from zope.interface import implements
 from zope.security.proxy import trustedRemoveSecurityProxy
+from zope.app.container.contained import Contained
 
-class Manager(Persistent):
+class Manager(Persistent, Contained):
 
     implements(IModuleManager, IAttributeAnnotatable)
 
-    zapi.ContextAwareDescriptors()
-
     def __init__(self, name, source):
         self.name = name
         self._source = None
@@ -58,7 +57,7 @@
             mod = self._module = PersistentModule(self.name)
 
 
-        folder = zapi.getWrapperContainer(self)
+        folder = self.__parent__
 
         # XXX
         # We are currently only supporting trusted code.
@@ -114,7 +113,7 @@
         assert name.endswith(".py")
         name = name[:-3]
         m = Manager(name, data)
-        m = zapi.ContextWrapper(m, self.context)
+        m.__parent__ = self.context
         m.execute()
         return m
 


=== Zope3/src/zope/app/services/principalannotation.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/services/principalannotation.py:1.9	Sat Jun  7 01:31:58 2003
+++ Zope3/src/zope/app/services/principalannotation.py	Sun Sep 21 13:31:59 2003
@@ -23,8 +23,6 @@
 from persistence.dict import PersistentDict
 from zodb.btrees.OOBTree import OOBTree
 from zope.app.component.nextservice import queryNextService
-from zope.context import ContextMethod
-from zope.app.context import ContextWrapper
 from zope.app.interfaces.annotation import IAnnotations
 from zope.interface import implements
 
@@ -32,8 +30,10 @@
 from zope.app.interfaces.services.principalannotation \
      import IPrincipalAnnotationService
 from zope.app.interfaces.services.service import ISimpleService
+from zope.app.container.contained import Contained
+from zope.app.location import Location
 
-class PrincipalAnnotationService(Persistent):
+class PrincipalAnnotationService(Persistent, Contained):
     """Stores IAnnotations for IPrinicipals.
 
     The service ID is 'PrincipalAnnotation'.
@@ -44,7 +44,6 @@
     def __init__(self):
         self.annotations = OOBTree()
 
-
     # implementation of IPrincipalAnnotationService
 
     def getAnnotations(self, principal):
@@ -54,7 +53,6 @@
         """
 
         return self.getAnnotationsById(principal.getId())
-    getAnnotations = ContextMethod(getAnnotations)
 
     def getAnnotationsById(self, principalId):
         """Return object implementing IAnnotations for the given principal.
@@ -65,17 +63,17 @@
         annotations = self.annotations.get(principalId)
         if annotations is None:
             annotations = Annotations(principalId, store=self.annotations)
+            annotations.__parent__ = self
+            annotations.__name__ = principalId
 
-        return ContextWrapper(annotations, self, name=principalId)
-
-    getAnnotationsById = ContextMethod(getAnnotationsById)
+        return annotations
 
     def hasAnnotations(self, principal):
         """Return boolean indicating if given principal has IAnnotations."""
         return principal.getId() in self.annotations
 
 
-class Annotations(Persistent):
+class Annotations(Persistent, Location):
     """Stores annotations."""
 
     implements(IAnnotations)
@@ -99,8 +97,6 @@
                     wrapped_self.principalId)
                 return annotations[key]
             raise
-
-    __getitem__ = ContextMethod(__getitem__)
 
     def __setitem__(self, key, value):
 


=== Zope3/src/zope/app/services/role.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/role.py:1.6	Thu Jun  5 08:03:17 2003
+++ Zope3/src/zope/app/services/role.py	Sun Sep 21 13:31:59 2003
@@ -22,7 +22,6 @@
 from zope.app.container.btree import BTreeContainer
 from zope.app.interfaces.security import IRoleService
 from zope.app.interfaces.container import IContainer
-from zope.context import ContextMethod
 from zope.app.component.nextservice import getNextService
 from zope.app.interfaces.services.service import ISimpleService
 from zope.interface import implements
@@ -47,7 +46,6 @@
             if sv:
                 return sv.getRole(rid)
             raise # will be original Key Error
-    getRole = ContextMethod(getRole)
 
     def getRoles(wrapped_self):
         '''See interface IRoleService'''
@@ -56,4 +54,3 @@
         if roleserv:
             roles.extend(roleserv.getRoles())
         return roles
-    getRoles = ContextMethod(getRoles)




More information about the Zope3-Checkins mailing list