[Checkins] SVN: five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt Added a test for making sure that utilities registered with the global site manager do not get an Acquisition context in any case.

Hanno Schlichting plone at hannosch.info
Wed Jun 6 09:10:05 EDT 2007


Log message for revision 76406:
  Added a test for making sure that utilities registered with the global site manager do not get an Acquisition context in any case.
  

Changed:
  U   five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt

-=-
Modified: five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt
===================================================================
--- five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt	2007-06-06 13:04:52 UTC (rev 76405)
+++ five.localsitemanager/trunk/src/five/localsitemanager/localsitemanager.txt	2007-06-06 13:10:05 UTC (rev 76406)
@@ -11,6 +11,7 @@
 
     >>> import zope.component
     >>> from zope.app.component.hooks import setSite as setActiveSite
+    >>> from zope.app.component.hooks import clearSite
 
     >>> from five.localsitemanager import make_objectmanager_site
     >>> make_objectmanager_site(site)
@@ -292,3 +293,58 @@
     >>> util1_1.aq_chain
     [<Utility AQTestUtility "util1_1">, <Folder at folder1/folder1_1>, <Folder at folder1>]
 
+
+Acquisition Context of Global Utilities
+---------------------------------------
+
+    >>> from zope.component import getGlobalSiteManager
+
+Register a utility with both of the nested site managers:
+
+    >>> gsm = getGlobalSiteManager()
+    >>> gsm.registerUtility(AQTestUtility('globalutil1'),
+    ...                     name=u'globalutil1',
+    ...                     provided=ITestUtility)
+
+    >>> sm1 = folder1.getSiteManager()
+    >>> sm1.registerUtility(AQTestUtility('localutil1'),
+    ...                     name=u'localutil1',
+    ...                     provided=ITestUtility)
+
+Lookup both utilities in the context of the global site manager:
+
+    >>> clearSite()
+    >>> globalutil1 = queryUtility(ITestUtility, name=u'globalutil1')
+    >>> globalutil1
+    <Utility AQTestUtility "globalutil1">
+
+    >>> getattr(globalutil1, 'aq_chain', None) is None
+    True
+
+The local utility isn't available in the global site manager:
+
+    >>> queryUtility(ITestUtility, name=u'localutil1') is None
+    True
+
+Lookup both utilities in the context of the local site manager:
+
+    >>> setActiveSite(folder1)
+    >>> globalutil1 = queryUtility(ITestUtility, name=u'globalutil1')
+    >>> globalutil1
+    <Utility AQTestUtility "globalutil1">
+
+We don't expect the global utility to get any Acquisition context:
+
+    >>> getattr(globalutil1, 'aq_chain', None) is None
+    True
+
+For the local utility we expect to get wrapped in the context of the local
+site manager:
+
+    >>> localutil1 = queryUtility(ITestUtility, name=u'localutil1')
+    >>> localutil1
+    <Utility AQTestUtility "localutil1">
+
+    >>> localutil1.aq_chain
+    [<Utility AQTestUtility "localutil1">, <Folder at folder1>]
+



More information about the Checkins mailing list