[Zope3-checkins] CVS: Zope3/src/zope/app/services - service.py:1.8.4.3
Guido van Rossum
guido@python.org
Thu, 27 Feb 2003 12:40:34 -0500
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv11630
Modified Files:
Tag: use-config-branch
service.py
Log Message:
- Get rid of a horrible hack ("_go_away") that was accidentally checked in.
- In ServiceConfiguration, when a service is activated, check that it
implements IService and IUseConfigurable. I really want to do that
in the constructor, but since the constructor is not a context
method, and only gets passed the service name and the path to the
service object, I see no way to actually retrieve the service object
and test it there (and I'm too chicken to make __init__ a context
method).
=== Zope3/src/zope/app/services/service.py 1.8.4.2 => 1.8.4.3 ===
--- Zope3/src/zope/app/services/service.py:1.8.4.2 Wed Feb 26 16:43:41 2003
+++ Zope3/src/zope/app/services/service.py Thu Feb 27 12:40:33 2003
@@ -58,6 +58,8 @@
from zope.app.services.configuration import NameComponentConfigurable
from zope.app.services.configuration import NamedComponentConfiguration
from zope.app.services.package import Packages
+from zope.component.interfaces import IService
+from zope.app.interfaces.services.configuration import IUseConfigurable
from zope.app.traversing import getPhysicalPathString
@@ -273,6 +275,10 @@
def activated(self):
service = self.getComponent()
+ if not IService.isImplementedBy(service):
+ raise TypeError, "service %r doesn't implement IService" % service
+ if not IUseConfigurable.isImplementedBy(service):
+ raise TypeError, "service %r doesn't implement IUseConfigurable" % service
if IBindingAware.isImplementedBy(service):
service.bound(self.name)
@@ -286,18 +292,6 @@
deactivated = ContextMethod(deactivated)
def manage_afterAdd(self, configuration, container):
- if _go_away:
- # XXX Sigh. The unit tests for InitDB() cause this to be
- # called, but setting up the proper environment is too
- # much work -- various services would have to be changed
- # to declare that they implement
- # IAttributeUseConfigurable; this is currently done in the
- # ZCML directives, but those aren't exected for the test
- # suite. Someday I'll find a proper fix -- for now,
- # there's a global flag that causes this method to become
- # a no-op.
- return
-
NamedComponentConfiguration.manage_afterAdd(self,
configuration,
container)