[Zope-Checkins] CVS: Zope3/lib/python/Zope/ComponentArchitecture - ServiceManagerContainer.py:1.1.2.1
Paul Everitt
paul@zope.com
Thu, 28 Feb 2002 15:23:51 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/ComponentArchitecture
In directory cvs.zope.org:/tmp/cvs-serv11288
Added Files:
Tag: Zope-3x-branch
ServiceManagerContainer.py
Log Message:
Refactored to use a base class for ServiceManagerContainer
=== Added File Zope3/lib/python/Zope/ComponentArchitecture/ServiceManagerContainer.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Revision information:
$Id: ServiceManagerContainer.py,v 1.1.2.1 2002/02/28 20:23:50 paul Exp $
"""
from IServiceManagerContainer import IServiceManagerContainer
from IServiceService import IServiceService
from Zope.ComponentArchitecture.Exceptions import ComponentLookupError
_marker = object()
class ServiceManagerContainer:
__implements__ = IServiceManagerContainer
############################################################
# Implementation methods for interface
# Zope.ComponentArchitecture.IServiceManagerContainer.
def hasServiceManager(self):
'''See interface IServiceManagerContainer'''
return hasattr(self, '_ServiceManagerContainer__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')
#
############################################################