[Zope3-checkins] CVS: Zope3/src/zope/app/services - registration.py:1.17

Fred L. Drake, Jr. fred at zope.com
Thu Oct 16 12:25:36 EDT 2003


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

Modified Files:
	registration.py 
Log Message:
RegistrationStatusProperty:  factor out how the service is located, to
allow subclasses to do things differently


=== Zope3/src/zope/app/services/registration.py 1.16 => 1.17 ===
--- Zope3/src/zope/app/services/registration.py:1.16	Wed Sep 24 16:43:13 2003
+++ Zope3/src/zope/app/services/registration.py	Thu Oct 16 12:25:36 2003
@@ -41,9 +41,7 @@
             return self
 
         registration = inst
-
-        sm = zapi.getServiceManager(registration)
-        service = sm.queryLocalService(registration.serviceType)
+        service = self._get_service(registration)
         registry = service and service.queryRegistrationsFor(registration)
 
         if registry:
@@ -57,10 +55,7 @@
 
     def __set__(self, inst, value):
         registration = inst
-
-        sm = zapi.getServiceManager(registration)
-        service = sm.queryLocalService(registration.serviceType)
-
+        service = self._get_service(registration)
         registry = service and service.queryRegistrationsFor(registration)
 
         if value == interfaces.UnregisteredStatus:
@@ -88,6 +83,12 @@
                 if not registry.registered(registration):
                     registry.register(registration)
                 registry.activate(registration)
+
+    def _get_service(self, registration):
+        # how we get the service is factored out so subclasses can
+        # approach this differently
+        sm = zapi.getServiceManager(registration)
+        return sm.queryLocalService(registration.serviceType)
 
 
 class RegistrationStack(Persistent, Contained):




More information about the Zope3-Checkins mailing list