[Checkins] SVN: zope.traversing/trunk/ Removed testing dependency on zope.app.publication.

Shane Hathaway shane at hathawaymix.org
Sun Dec 27 01:55:16 EST 2009


Log message for revision 107143:
  Removed testing dependency on zope.app.publication.
  

Changed:
  U   zope.traversing/trunk/CHANGES.txt
  U   zope.traversing/trunk/setup.py
  U   zope.traversing/trunk/src/zope/traversing/publicationtraverse.py
  U   zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml
  U   zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py

-=-
Modified: zope.traversing/trunk/CHANGES.txt
===================================================================
--- zope.traversing/trunk/CHANGES.txt	2009-12-27 06:48:17 UTC (rev 107142)
+++ zope.traversing/trunk/CHANGES.txt	2009-12-27 06:55:16 UTC (rev 107143)
@@ -5,6 +5,7 @@
 3.10.1 (unreleased)
 -------------------
 
+- Removed testing dependency on zope.app.publication.
 
 3.10.0 (2009-12-16)
 -------------------

Modified: zope.traversing/trunk/setup.py
===================================================================
--- zope.traversing/trunk/setup.py	2009-12-27 06:48:17 UTC (rev 107142)
+++ zope.traversing/trunk/setup.py	2009-12-27 06:55:16 UTC (rev 107143)
@@ -38,8 +38,7 @@
       packages=find_packages('src'),
       package_dir = {'': 'src'},
       namespace_packages=['zope',],
-      extras_require = dict(test=['zope.app.publication',
-                                  'zope.browserpage',
+      extras_require = dict(test=['zope.browserpage',
                                   'zope.browserresource',
                                   'zope.configuration',
                                   'zope.container',

Modified: zope.traversing/trunk/src/zope/traversing/publicationtraverse.py
===================================================================
--- zope.traversing/trunk/src/zope/traversing/publicationtraverse.py	2009-12-27 06:48:17 UTC (rev 107142)
+++ zope.traversing/trunk/src/zope/traversing/publicationtraverse.py	2009-12-27 06:55:16 UTC (rev 107143)
@@ -43,6 +43,8 @@
     - This version has a method, traverseRelativeURL(), that
       supports "browserDefault" traversal.
     """
+    def proxy(self, ob):
+        return ProxyFactory(ob)
 
     def traverseName(self, request, ob, name):
         nm = name # the name to look up the object with
@@ -56,7 +58,7 @@
                 except TraversalError:
                     raise NotFound(ob, name)
 
-                return ProxyFactory(ob2)
+                return self.proxy(ob2)
 
         if nm == '.':
             return ob
@@ -72,7 +74,7 @@
             else:
                 raise NotFound(ob, name, request)
 
-        return ProxyFactory(ob2)
+        return self.proxy(ob2)
 
     def traversePath(self, request, ob, path):
 
@@ -113,7 +115,7 @@
             if adapter is None:
                 return ob
             ob, path = adapter.browserDefault(request)
-            ob = ProxyFactory(ob)
+            ob = self.proxy(ob)
             if not path:
                 return ob
 
@@ -121,3 +123,8 @@
 
 # alternate spelling
 PublicationTraverse = PublicationTraverser
+
+class PublicationTraverserWithoutProxy(PublicationTraverse):
+
+    def proxy(self, ob):
+        return ob

Modified: zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml
===================================================================
--- zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml	2009-12-27 06:48:17 UTC (rev 107142)
+++ zope.traversing/trunk/src/zope/traversing/tests/ftesting.zcml	2009-12-27 06:55:16 UTC (rev 107143)
@@ -10,7 +10,6 @@
   <include package="zope.publisher" file="meta.zcml" />
   <include package="zope.security" file="meta.zcml" />
   <include package="zope.securitypolicy" file="meta.zcml" />
-  <include package="zope.app.publication" file="meta.zcml" />
 
   <include package="zope.browserresource" />
   <include package="zope.container" />
@@ -21,8 +20,6 @@
   <include package="zope.site" />
   <include package="zope.traversing" />
 
-  <include package="zope.app.publication" />
-
   <browser:defaultView name="index.html" />
   <include package="zope.traversing.browser" />
 

Modified: zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py
===================================================================
--- zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py	2009-12-27 06:48:17 UTC (rev 107142)
+++ zope.traversing/trunk/src/zope/traversing/tests/test_vhosting.py	2009-12-27 06:55:16 UTC (rev 107143)
@@ -20,12 +20,7 @@
 from StringIO import StringIO
 
 import transaction
-from persistent import Persistent
-from ZODB.DB import DB
-from ZODB.DemoStorage import DemoStorage
 
-from zope.app.publication.browser import BrowserPublication
-
 from zope.browserresource.resource import Resource
 from zope.configuration import xmlconfig
 from zope.container.contained import Contained
@@ -48,7 +43,7 @@
         return traverse(self, '/foo/bar/' + key)
 
 
-class MyPageTemplate(AppPT, PageTemplate, Persistent):
+class MyPageTemplate(AppPT, PageTemplate):
 
     def pt_getContext(self, instance, request, **_kw):
         # instance is a View component
@@ -84,16 +79,11 @@
     def setUp(self):
         f = os.path.join(os.path.split(__file__)[0], 'ftesting.zcml')
         xmlconfig.file(f)
-        self.db = DB(DemoStorage("Memory storage unnamed"))
-        self.connection = self.db.open()
-        root = self.connection.root()
-        root_folder = rootFolder()
-        root['Application'] = root_folder
+        self.app = rootFolder()
         defineChecker(MyObj, NoProxy)
 
     def tearDown(self):
         undefineChecker(MyObj)
-        self.connection.close()
         cleanUp()
 
     def makeRequest(self, path=''):
@@ -104,7 +94,7 @@
             env['PATH_INFO'] = p[0]
 
         request = BrowserRequest(StringIO(''), env)
-        request.setPublication(BrowserPublication(self.db))
+        request.setPublication(DummyPublication(self.app))
         setDefaultSkin(request)
         return request
 
@@ -181,7 +171,7 @@
         """addFolders('/a/b/c/d') would traverse and/or create three nested
         folders (a, b, c) and return a tuple (c, 'd') where c is a Folder
         instance at /a/b/c."""
-        folder = self.connection.root()['Application']
+        folder = self.app  #self.connection.root()['Application']
         if path[0] == '/':
             path = path[1:]
         path = path.split('/')
@@ -214,6 +204,88 @@
         self.assertEquals(result.getHeader('Location'), location)
 
 
+class DummyPublication:
+
+    def __init__(self, app):
+        self.app = app
+
+    def beforeTraversal(self, request):
+        """Pre-traversal hook.
+
+        This is called *once* before any traversal has been done.
+        """
+
+    def getApplication(self, request):
+        """Returns the object where traversal should commence.
+        """
+        return self.app
+
+    def callTraversalHooks(self, request, ob):
+        """Invokes any traversal hooks associated with the object.
+
+        This is called before traversing each object.  The ob argument
+        is the object that is about to be traversed.
+        """
+
+    def traverseName(self, request, ob, name):
+        """Traverses to the next object.
+
+        Name must be an ASCII string or Unicode object."""
+        if name == 'index.html':
+            from zope.component import queryMultiAdapter
+            view = queryMultiAdapter((ob, request), name=name)
+            if view is None:
+                from zope.publisher.interfaces import NotFound
+                raise NotFound(ob, name)
+            return view
+        else:
+            from zope.traversing.publicationtraverse \
+                import PublicationTraverserWithoutProxy
+            t = PublicationTraverserWithoutProxy()
+            return t.traverseName(request, ob, name)
+
+    def afterTraversal(self, request, ob):
+        """Post-traversal hook.
+
+        This is called after all traversal.
+        """
+
+    def callObject(self, request, ob):
+        """Call the object, returning the result.
+
+        For GET/POST this means calling it, but for other methods
+        (including those of WebDAV and FTP) this might mean invoking
+        a method of an adapter.
+        """
+        from zope.publisher.publish import mapply
+        return mapply(ob, request.getPositionalArguments(), request)
+
+    def afterCall(self, request, ob):
+        """Post-callObject hook (if it was successful).
+        """
+
+    def handleException(self, ob, request, exc_info, retry_allowed=1):
+        """Handle an exception
+
+        Either:
+        - sets the body of the response, request.response, or
+        - raises a Retry exception, or
+        - throws another exception, which is a Bad Thing.
+        """
+        import traceback
+        traceback.print_exception(*exc_info)
+
+    def endRequest(self, request, ob):
+        """Do any end-of-request cleanup
+        """
+
+    def getDefaultTraversal(self, request, ob):
+        if hasattr(ob, 'index'):
+            return ob, ()
+        else:
+            return ob, ('index.html',)
+
+
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(TestVirtualHosting))



More information about the checkins mailing list