[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture/tests - testServiceManagerContainer.py:1.1.2.3
Paul Everitt
paul@zope.com
Thu, 28 Feb 2002 15:23:27 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture/tests
In directory cvs.zope.org:/tmp/cvs-serv11260/tests
Modified Files:
Tag: Zope-3x-branch
testServiceManagerContainer.py
Log Message:
Refactored to use a base class for ServiceManagerContainer
=== Zope3/lib/python/Zope/ComponentArchitecture/tests/testServiceManagerContainer.py 1.1.2.2 => 1.1.2.3 ===
from Zope.ComponentArchitecture.IServiceService import IServiceService
from Zope.ComponentArchitecture.IServiceManagerContainer import IServiceManagerContainer
+from Zope.ComponentArchitecture.ServiceManagerContainer import ServiceManagerContainer
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
-_marker = object()
-
class ServiceManager:
__implements__ = IServiceService
@@ -40,41 +39,6 @@
def getServiceDefinitions(self):
'''See interface IServiceService'''
return ()
-
- #
- ############################################################
-
-class ServiceManagerContainer:
-
- __implements__ = IServiceManagerContainer
-
- ############################################################
- # Implementation methods for interface
- # Zope.ComponentArchitecture.IServiceManagerContainer.
-
- def hasServiceManager(self):
- '''See interface IServiceManagerContainer'''
-
- return hasattr(self, 'sm')
-
- def getServiceManager(self, default=_marker):
- '''See interface IServiceManagerContainer'''
-
- try:
- return self.sm
- except AttributeError:
- if default is _marker:
- raise ComponentLookupError
- else:
- return default
-
- def setServiceManager(self, sm):
- '''See interface IServiceManagerContainer'''
-
- if IServiceService.isImplementedBy(sm):
- self.sm = sm
- else:
- raise ValueError('setServiceManager requires an IServiceService')
#
############################################################