[Checkins] SVN: zope.app.publication/trunk/ fire start request event (Robert Collins)

Gary Poster gary.poster at canonical.com
Fri Jul 16 08:21:20 EDT 2010


Log message for revision 114795:
  fire start request event (Robert Collins)

Changed:
  U   zope.app.publication/trunk/CHANGES.txt
  U   zope.app.publication/trunk/setup.py
  U   zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py
  U   zope.app.publication/trunk/src/zope/app/publication/zopepublication.py

-=-
Modified: zope.app.publication/trunk/CHANGES.txt
===================================================================
--- zope.app.publication/trunk/CHANGES.txt	2010-07-16 06:21:46 UTC (rev 114794)
+++ zope.app.publication/trunk/CHANGES.txt	2010-07-16 12:21:19 UTC (rev 114795)
@@ -2,10 +2,11 @@
 CHANGES
 =======
 
-3.11.2 (unreleased)
+3.12.0 (unreleased)
 -------------------
 
-- Nothing changed yet.
+- Notify with IStartRequestEvent at the start of the request publication
+  cycle.
 
 
 3.11.1 (2010-04-19)

Modified: zope.app.publication/trunk/setup.py
===================================================================
--- zope.app.publication/trunk/setup.py	2010-07-16 06:21:46 UTC (rev 114794)
+++ zope.app.publication/trunk/setup.py	2010-07-16 12:21:19 UTC (rev 114795)
@@ -72,7 +72,7 @@
                       'zope.error',
                       'zope.browser>=1.2',
                       'zope.location',
-                      'zope.publisher>=3.12',
+                      'zope.publisher>=3.12.4',
                       'zope.traversing>=3.9.0',
                       'setuptools',
                       ],

Modified: zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py	2010-07-16 06:21:46 UTC (rev 114794)
+++ zope.app.publication/trunk/src/zope/app/publication/tests/test_zopepublication.py	2010-07-16 12:21:19 UTC (rev 114795)
@@ -574,18 +574,32 @@
         self.assertEqual(txn_info['location'], expected_path)
 
     def testSiteEvents(self):
-        from zope.publisher.interfaces import IEndRequestEvent
+        from zope.publisher.interfaces import (
+            IEndRequestEvent,
+            IStartRequestEvent,
+            )
         from zope.traversing.interfaces import IBeforeTraverseEvent
 
+        start = []
         set = []
         clear = []
 
+        component.provideHandler(start.append, (IStartRequestEvent,))
         component.provideHandler(set.append, (IBeforeTraverseEvent,))
         component.provideHandler(clear.append, (IEndRequestEvent,))
 
         ob = object()
 
-        # This should fire the BeforeTraverseEvent
+        # The request is started at the top of publication, which tries to do
+        # auth.  Let's register an unauthenticated principal instance.
+        principal = UnauthenticatedPrincipal('fallback')
+        component.provideUtility(principal, IFallbackUnauthenticatedPrincipal)
+        # Start publication.
+        self.publication.beforeTraversal(self.request)
+        self.assertEqual(len(start), 1)
+        self.assertEqual(start[0].request, self.request)
+
+        # This should fire the BeforeTraverseEvent.
         self.publication.callTraversalHooks(self.request, ob)
 
         self.assertEqual(len(set), 1)
@@ -597,6 +611,7 @@
         # This should fire the EndRequestEvent
         self.publication.endRequest(self.request, ob2)
 
+        self.assertEqual(len(start), 1)
         self.assertEqual(len(set), 1)
         self.assertEqual(len(clear), 1)
         self.assertEqual(clear[0].object, ob2)

Modified: zope.app.publication/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/zopepublication.py	2010-07-16 06:21:46 UTC (rev 114794)
+++ zope.app.publication/trunk/src/zope/app/publication/zopepublication.py	2010-07-16 12:21:19 UTC (rev 114795)
@@ -44,7 +44,7 @@
 import zope.authentication.interfaces
 from zope.browser.interfaces import ISystemErrorView
 from zope.publisher.defaultview import queryDefaultViewName
-from zope.publisher.interfaces import EndRequestEvent
+from zope.publisher.interfaces import EndRequestEvent, StartRequestEvent
 from zope.authentication.interfaces import IUnauthenticatedPrincipal
 from zope.authentication.interfaces import IFallbackUnauthenticatedPrincipal
 from zope.authentication.interfaces import IAuthentication
@@ -67,6 +67,7 @@
                 "Cleanup without request close")
             self._f()
 
+
 class ZopePublication(object):
     """Base Zope publication specification."""
     implements(IPublication)
@@ -86,6 +87,7 @@
         return ProxyFactory(ob)
 
     def beforeTraversal(self, request):
+        notify(StartRequestEvent(request))
         # Try to authenticate against the root authentication utility.
         auth = zope.component.getGlobalSiteManager().getUtility(
             zope.authentication.interfaces.IAuthentication)



More information about the checkins mailing list