[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication - PublicationTraverse.py:1.1.2.13 ZopePublication.py:1.1.2.34

Jim Fulton jim@zope.com
Tue, 9 Apr 2002 06:24:50 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication
In directory cvs.zope.org:/tmp/cvs-serv1240/Zope/App/ZopePublication

Modified Files:
      Tag: Zope-3x-branch
	PublicationTraverse.py ZopePublication.py 
Log Message:
Added new name to the etc namespace, ApplicationController. This is an
object that provides global application control. It is similar to the
Zope2 control panel. It *is not* stored in the object database, so you
can get to it even if your database is toast or your root object is
messed up.

It's handled kind of weirdly, since it's effectively an alternative 
application object.



=== Zope3/lib/python/Zope/App/ZopePublication/PublicationTraverse.py 1.1.2.12 => 1.1.2.13 ===
 from Zope.App.ZMI.Addable import ContentAddables
 from Zope.App.OFS.Container.IContainer import IWriteContainer
+from Zope.App.OFS.ApplicationControl.ApplicationControl \
+     import ApplicationController
 
 class DuplicateNamespaces(Exception):
     """More than one namespave was specified in a request"""
@@ -128,6 +130,9 @@
         # not all get methods may satisfy this assumption. It might be
         # best to introduce some sort of etc registry.
 
+        if name == 'ApplicationController' and ob is None:
+            return self.__etcApplicationController()
+
         if name != 'Services':
             raise NotFound(ob, name, request)
             
@@ -140,6 +145,9 @@
         self._wrap(method, ob, name, name)
 
         return method()
+
+    def __etcApplicationController(self):
+        return ApplicationController
 
     def _traverseacquire(self, request, ob, name):
         i = 0


=== Zope3/lib/python/Zope/App/ZopePublication/ZopePublication.py 1.1.2.33 => 1.1.2.34 ===
 
     def getApplication(self, request):
+
+        # If the first name is 'ApplicationControl;etc', then we should
+        # get it rather than look in the database!
+        stack = request.getTraversalStack()
+        if stack:
+            name = stack[-1]
+            if name[:22] == 'ApplicationController;':
+                parms = name.split(';')
+                if 'etc' in parms or 'ns=etc' in parms:
+                    stack.pop() # consume the name
+                    request.setTraversalStack(stack) # Reset the stack
+                    return self.traverseName(request, None, name)
+        
         # Open the database.
         version = request.get(self.version_cookie, '')
         conn = self.db.open(version)