[Zope3-checkins] CVS: Zope3/src/zope/component - service.py:1.3
R. David Murray
bitz@bitdance.com
Fri, 27 Dec 2002 20:42:22 -0500
Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv32093
Modified Files:
service.py
Log Message:
Add a force keyword to provideService to allow replacement of an
existing registration, to facilitate writing unit tests (at Jim's
suggestion).
=== Zope3/src/zope/component/service.py 1.2 => 1.3 ===
--- Zope3/src/zope/component/service.py:1.2 Wed Dec 25 09:13:31 2002
+++ Zope3/src/zope/component/service.py Fri Dec 27 20:42:21 2002
@@ -70,10 +70,14 @@
"""see IServiceService Interface"""
return self.__defs.items()
- def provideService(self, name, component):
- """see IGlobalServiceManager interface, above"""
+ def provideService(self, name, component, force=False):
+ """see IGlobalServiceManager interface, above
+
+ The force keyword allows one to replace an existing
+ service. This is mostly useful in testing scenarios.
+ """
- if name in self.__services:
+ if not force and name in self.__services:
raise DuplicationError(name)
if name not in self.__defs: