[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/app/testing/setup.py
Simplified addUtility, reflecting the new simpler registration apis.
Jim Fulton
jim at zope.com
Sun Apr 2 12:59:12 EDT 2006
Log message for revision 66297:
Simplified addUtility, reflecting the new simpler registration apis.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/testing/setup.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/testing/setup.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/testing/setup.py 2006-04-02 16:59:09 UTC (rev 66296)
+++ Zope3/branches/jim-adapter/src/zope/app/testing/setup.py 2006-04-02 16:59:11 UTC (rev 66297)
@@ -173,20 +173,17 @@
#------------------------------------------------------------------------
# Local Utility Addition
-from zope.app.component.site import UtilityRegistration
-from zope.app.component.interfaces.registration import ActiveStatus
def addUtility(sitemanager, name, iface, utility, suffix=''):
"""Add a utility to a site manager
This helper function is useful for tests that need to set up utilities.
"""
folder_name = (name or (iface.__name__ + 'Utility')) + suffix
- default = zapi.traverse(sitemanager, 'default')
+ default = sitemanager['default']
default[folder_name] = utility
- registration = UtilityRegistration(name, iface, default[folder_name])
- key = default.registrationManager.addRegistration(registration)
- zapi.traverse(default.registrationManager, key).status = ActiveStatus
- return default[folder_name]
+ utility = default[folder_name]
+ sitemanager.registerUtility(utility, iface, name)
+ return utility
#------------------------------------------------------------------------
More information about the Zope3-Checkins
mailing list