[Checkins] SVN: zope.traversing/trunk/ Look up the application controller through a utility registration

Shane Hathaway shane at hathawaymix.org
Sat May 23 16:22:30 EDT 2009


Log message for revision 100292:
  Look up the application controller through a utility registration
  rather than a direct reference.
  

Changed:
  U   zope.traversing/trunk/CHANGES.txt
  U   zope.traversing/trunk/setup.py
  U   zope.traversing/trunk/src/zope/traversing/interfaces.py
  U   zope.traversing/trunk/src/zope/traversing/namespace.py
  U   zope.traversing/trunk/src/zope/traversing/tests/test_etc.py

-=-
Modified: zope.traversing/trunk/CHANGES.txt
===================================================================
--- zope.traversing/trunk/CHANGES.txt	2009-05-23 20:21:33 UTC (rev 100291)
+++ zope.traversing/trunk/CHANGES.txt	2009-05-23 20:22:30 UTC (rev 100292)
@@ -9,7 +9,10 @@
   zope.app.publisher -> zope.app.publication dependency (which was a
   cycle).
 
+- Look up the application controller through a utility registration
+  rather than a direct reference.
 
+
 3.6.0 (2009-04-06)
 ------------------
 

Modified: zope.traversing/trunk/setup.py
===================================================================
--- zope.traversing/trunk/setup.py	2009-05-23 20:21:33 UTC (rev 100291)
+++ zope.traversing/trunk/setup.py	2009-05-23 20:22:30 UTC (rev 100292)
@@ -37,7 +37,7 @@
                                   'zope.app.securitypolicy',
                                   'zope.app.zcmlfiles',
                                   'zope.app.zptpage',
-                                  'zope.app.applicationcontrol',
+                                  'zope.app.applicationcontrol>=3.5.0',
                                   'zope.app.component',
                                   'zope.container',
                                   'zope.site',

Modified: zope.traversing/trunk/src/zope/traversing/interfaces.py
===================================================================
--- zope.traversing/trunk/src/zope/traversing/interfaces.py	2009-05-23 20:21:33 UTC (rev 100291)
+++ zope.traversing/trunk/src/zope/traversing/interfaces.py	2009-05-23 20:22:30 UTC (rev 100292)
@@ -139,3 +139,7 @@
 class IPathAdapter(Interface):
     """Marker interface for adapters to be used in paths
     """
+
+class IEtcNamespace(Interface):
+    """Marker for utility registrations in the ++etc++ namespace
+    """

Modified: zope.traversing/trunk/src/zope/traversing/namespace.py
===================================================================
--- zope.traversing/trunk/src/zope/traversing/namespace.py	2009-05-23 20:21:33 UTC (rev 100291)
+++ zope.traversing/trunk/src/zope/traversing/namespace.py	2009-05-23 20:22:30 UTC (rev 100292)
@@ -28,7 +28,9 @@
 from zope.publisher.interfaces.browser import IBrowserSkinType
 from zope.publisher.skinnable import applySkin
 from zope.security.proxy import removeSecurityProxy
-from zope.traversing.interfaces import ITraversable, IPathAdapter
+from zope.traversing.interfaces import IEtcNamespace
+from zope.traversing.interfaces import IPathAdapter
+from zope.traversing.interfaces import ITraversable
 
 
 class UnexpectedParameters(LocationError):
@@ -294,31 +296,12 @@
 class etc(SimpleHandler):
 
     def traverse(self, name, ignored):
-        # TODO:
-        # This is here now to allow us to get site managers from a
-        # separate namespace from the content. We add and etc
-        # namespace to allow us to handle misc objects.  We'll apply
-        # YAGNI for now and hard code this. We'll want something more
-        # general later. We were thinking of just calling "get"
-        # methods, but this is probably too magic. In particular, we
-        # will treat returned objects as sub-objects wrt security and
-        # not all get methods may satisfy this assumption. It might be
-        # best to introduce some sort of etc registry.
+        utility = zope.component.queryUtility(IEtcNamespace, name)
+        if utility is not None:
+            return utility
 
         ob = self.context
 
-        if (name in ('process', 'ApplicationController')
-            and IRoot.providedBy(ob)):
-            # import the application controller here to avoid circular
-            # import problems
-            try:
-                from zope.app.applicationcontrol.applicationcontrol \
-                     import applicationController
-            except ImportError:
-                pass
-            else:
-                return applicationController
-
         if name not in ('site',):
             raise LocationError(ob, name)
 

Modified: zope.traversing/trunk/src/zope/traversing/tests/test_etc.py
===================================================================
--- zope.traversing/trunk/src/zope/traversing/tests/test_etc.py	2009-05-23 20:21:33 UTC (rev 100291)
+++ zope.traversing/trunk/src/zope/traversing/tests/test_etc.py	2009-05-23 20:22:30 UTC (rev 100292)
@@ -30,9 +30,13 @@
         # zope.app.applicationcontrol, its tests do, so we always test the
         # behaviour in the case that the application controller is present.
 
+        import zope.component
+        from zope.traversing.interfaces import IEtcNamespace
         from zope.traversing.namespace import etc
         from zope.app.applicationcontrol.applicationcontrol \
              import applicationController, applicationControllerRoot
+        gsm = zope.component.getGlobalSiteManager()
+        gsm.registerUtility(applicationController, IEtcNamespace, 'process')
 
         self.assertEqual(
             etc(applicationControllerRoot).traverse('process', ()),



More information about the Checkins mailing list