[Zope3-checkins] CVS: Zope3/src/zope/app/tests - setup.py:1.9
Sidnei da Silva
sidnei at x3ng.com.br
Mon Feb 2 15:48:34 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/tests
In directory cvs.zope.org:/tmp/cvs-serv28267/src/zope/app/tests
Modified Files:
setup.py
Log Message:
Helper for adding utilities, and a missing i18n_domain
=== Zope3/src/zope/app/tests/setup.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/tests/setup.py:1.8 Fri Nov 21 12:12:14 2003
+++ Zope3/src/zope/app/tests/setup.py Mon Feb 2 15:48:01 2004
@@ -152,6 +152,20 @@
zapi.traverse(default.getRegistrationManager(), key).status = ActiveStatus
return zapi.traverse(servicemanager, path)
+from zope.app.services.utility import UtilityRegistration
+
+def addUtility(servicemanager, name, iface, utility, suffix=''):
+ """Add a utility to a service manager
+
+ This utility is useful for tests that need to set up utilities.
+ """
+ default = zapi.traverse(servicemanager, 'default')
+ default[name+suffix] = utility
+ path = "%s/default/%s" % (zapi.getPath(servicemanager), name+suffix)
+ registration = UtilityRegistration(name, iface, path)
+ key = default.getRegistrationManager().addRegistration(registration)
+ zapi.traverse(default.getRegistrationManager(), key).status = ActiveStatus
+ return zapi.traverse(servicemanager, path)
from zope.component import getServiceManager
from zope.app.interfaces.services.hub import IObjectHub
More information about the Zope3-Checkins
mailing list