[Checkins] SVN: zope.component/trunk/ The ZCML directives provided by zope.component now register the components in
Fabio Tranchitella
kobold at kobold.it
Thu Mar 4 14:49:14 EST 2010
Log message for revision 109656:
The ZCML directives provided by zope.component now register the components in
the registry returned by getSiteManager instead of the global registry. This
allows the hooking of the getSiteManager method before the load of a ZCML file
to register the components in a custom registry.
Changed:
U zope.component/trunk/CHANGES.txt
U zope.component/trunk/src/zope/component/tests.py
U zope.component/trunk/src/zope/component/zcml.py
U zope.component/trunk/src/zope/component/zcml.txt
U zope.component/trunk/src/zope/component/zcml_conditional.txt
-=-
Modified: zope.component/trunk/CHANGES.txt
===================================================================
--- zope.component/trunk/CHANGES.txt 2010-03-04 18:31:26 UTC (rev 109655)
+++ zope.component/trunk/CHANGES.txt 2010-03-04 19:49:14 UTC (rev 109656)
@@ -4,7 +4,10 @@
3.9.3 (unreleased)
==================
-- No changes yet.
+- The ZCML directives provided by zope.component now register the components in
+ the registry returned by getSiteManager instead of the global registry. This
+ allows the hooking of the getSiteManager method before the load of a ZCML
+ file to register the components in a custom registry.
3.9.2 (2010-01-22)
==================
Modified: zope.component/trunk/src/zope/component/tests.py
===================================================================
--- zope.component/trunk/src/zope/component/tests.py 2010-03-04 18:31:26 UTC (rev 109655)
+++ zope.component/trunk/src/zope/component/tests.py 2010-03-04 19:49:14 UTC (rev 109656)
@@ -1090,6 +1090,28 @@
"""
+def test_zcml_handler_site_manager():
+ """
+ The ZCML directives provided by zope.component use the ``getSiteManager``
+ method to get the registry where to register the components. This makes
+ possible to hook ``getSiteManager`` before loading a ZCML file:
+
+ >>> from zope.component.registry import Components
+ >>> registry = Components()
+ >>> def dummy(context=None):
+ ... return registry
+ >>> from zope.component import getSiteManager
+ >>> ignore = getSiteManager.sethook(dummy)
+
+ >>> from zope.component.testfiles.components import comp, IApp
+ >>> from zope.component.zcml import handler
+ >>> handler('registerUtility', comp, IApp, u'')
+ >>> registry.getUtility(IApp) is comp
+ True
+ >>> ignore = getSiteManager.reset()
+
+ """
+
class StandaloneTests(unittest.TestCase):
def testStandalone(self):
import subprocess
Modified: zope.component/trunk/src/zope/component/zcml.py
===================================================================
--- zope.component/trunk/src/zope/component/zcml.py 2010-03-04 18:31:26 UTC (rev 109655)
+++ zope.component/trunk/src/zope/component/zcml.py 2010-03-04 19:49:14 UTC (rev 109656)
@@ -45,7 +45,7 @@
"supported because zope.security is not available")
def handler(methodName, *args, **kwargs):
- method = getattr(zope.component.getGlobalSiteManager(), methodName)
+ method = getattr(zope.component.getSiteManager(), methodName)
method(*args, **kwargs)
class IBasicComponentInformation(zope.interface.Interface):
Modified: zope.component/trunk/src/zope/component/zcml.txt
===================================================================
--- zope.component/trunk/src/zope/component/zcml.txt 2010-03-04 18:31:26 UTC (rev 109655)
+++ zope.component/trunk/src/zope/component/zcml.txt 2010-03-04 19:49:14 UTC (rev 109656)
@@ -561,8 +561,8 @@
Note how ZCML provides some additional information when registering
components, such as the ZCML filename and line numbers:
- >>> gsm = zope.component.getGlobalSiteManager()
- >>> doc = [reg.info for reg in gsm.registeredSubscriptionAdapters()
+ >>> sm = zope.component.getSiteManager()
+ >>> doc = [reg.info for reg in sm.registeredSubscriptionAdapters()
... if reg.provided is IS][0]
>>> print doc
File "<string>", line 4.2-9.8
Modified: zope.component/trunk/src/zope/component/zcml_conditional.txt
===================================================================
--- zope.component/trunk/src/zope/component/zcml_conditional.txt 2010-03-04 18:31:26 UTC (rev 109655)
+++ zope.component/trunk/src/zope/component/zcml_conditional.txt 2010-03-04 19:49:14 UTC (rev 109656)
@@ -321,8 +321,8 @@
Note how ZCML provides some additional information when registering
components, such as the ZCML filename and line numbers:
- >>> gsm = zope.component.getGlobalSiteManager()
- >>> doc = [reg.info for reg in gsm.registeredSubscriptionAdapters()
+ >>> sm = zope.component.getSiteManager()
+ >>> doc = [reg.info for reg in sm.registeredSubscriptionAdapters()
... if reg.provided is IS][0]
>>> print doc
File "<string>", line 4.2-9.8
More information about the checkins
mailing list