[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ServiceManager - ServiceManager.py:1.8.6.3
Suresh Babu Eddala
sbabu@zeomega.com
Mon, 21 Oct 2002 12:07:57 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ServiceManager
In directory cvs.zope.org:/tmp/cvs-serv12861/lib/python/Zope/App/OFS/Services/ServiceManager
Modified Files:
Tag: Zope3-Bangalore-TTW-Branch
ServiceManager.py
Log Message:
Implementaion of getRegistrationState Method to get the status of the ServiceDirective
=== Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py 1.8.6.2 => 1.8.6.3 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py:1.8.6.2 Fri Oct 18 10:22:29 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ServiceManager/ServiceManager.py Mon Oct 21 12:07:57 2002
@@ -47,20 +47,26 @@
from Package import Package
from IServiceManager import IServiceManager
+from Persistence.Module import PersistentModuleRegistry
from Persistence.Module import PersistentModuleRegistry, PersistentModule
-
from INameResolver import INameResolver
ModuleType = type(INameResolver)
ModuleType = ModuleType, PersistentModule
+
class ServiceManager(Persistent,
PersistentModuleRegistry):
+
+ __implements__ = (IServiceManager, ISimpleReadContainer,
+ PersistentModuleRegistry.__implements__)
+
__implements__ = (IServiceManager, ISimpleReadContainer,
PersistentModuleRegistry.__implements__,
INameResolver)
+
def __init__(self):
super(ServiceManager, self).__init__()
self.__bindings = {}
@@ -201,6 +207,7 @@
def bindService(self, directive):
"See "
"Zope.App.OFS.Services.ServiceManager.IServiceManager.IServiceManager"
+
service = directive.getService(self)
service_type = directive.service_type
@@ -231,19 +238,19 @@
"Zope.App.OFS.Services.ServiceManager.IServiceManager.IServiceManager"
service = directive.getService(self)
service_type = directive.service_type
-
interface = self.getInterfaceFor(service_type)
if not interface.isImplementedBy(service):
raise InvalidService(service_type, directive, interface)
bindings = self.__bindings
+
if service_type not in bindings:
bindings[service_type] = []
bindings[service_type].append(directive)
self._p_changed = 1
-
+
if len(bindings) == 1:
aware_service = queryAdapter(service, IBindingAware)
if aware_service is not None:
@@ -253,6 +260,7 @@
def unbindService(self, directive):
"See Zope.App.OFS.Services.ServiceManager.IServiceManager.IServiceManager"
+
service = directive.getService(self) # must be before unwrapping self
self = removeAllProxies(self)
service_type = directive.service_type
@@ -269,7 +277,7 @@
if d != directive]
self._p_changed = 1
-
+
unbindService = ContextMethod(unbindService)
def getDirectives(self, service_type):
@@ -280,6 +288,19 @@
def getBoundServiceTypes(self):
"See Zope.App.OFS.Services.ServiceManager.IServiceManager.IServiceManager"
return self.__bindings.keys()
+
+ def getRegistrationState(self, directive, service_type):
+ "See Zope.ComponentArchitecture.IServiceService.IServiceService"
+ directives = self.__bindings[service_type]
+ if directives:
+ if directives[0] == directive:
+ return 'Active'
+ elif directive in directives:
+ return 'Registered'
+ else:
+ return 'UnRegistered'
+ else:
+ return 'UnRegistered'
############################################################
@@ -387,3 +408,4 @@
mod += '.' + last
resolve = ContextMethod(resolve)
+