[Checkins] SVN: zope.app.publication/trunk/ Moved registration of and tests for two publication-specific event handlers

Thomas Lotze tl at gocept.com
Tue Sep 29 02:14:18 EDT 2009


Log message for revision 104598:
  Moved registration of and tests for two publication-specific event handlers
  here from zope.site in order to invert the package dependency.
  

Changed:
  U   zope.app.publication/trunk/CHANGES.txt
  U   zope.app.publication/trunk/setup.py
  U   zope.app.publication/trunk/src/zope/app/publication/configure.zcml
  A   zope.app.publication/trunk/src/zope/app/publication/site.txt
  U   zope.app.publication/trunk/src/zope/app/publication/tests/test_functional.py

-=-
Modified: zope.app.publication/trunk/CHANGES.txt
===================================================================
--- zope.app.publication/trunk/CHANGES.txt	2009-09-29 05:34:24 UTC (rev 104597)
+++ zope.app.publication/trunk/CHANGES.txt	2009-09-29 06:14:18 UTC (rev 104598)
@@ -2,12 +2,15 @@
 CHANGES
 =======
 
-3.8.2 (unreleased)
+3.9.0 (unreleased)
 ------------------
 
 - An abort within handleExceptions could have failed without logging what
   caused the error. It now logs the original problem.
 
+- Moved registration of and tests for two publication-specific event handlers
+  here from zope.site in order to invert the package dependency.
+
 3.8.1 (2009-06-21)
 ------------------
 

Modified: zope.app.publication/trunk/setup.py
===================================================================
--- zope.app.publication/trunk/setup.py	2009-09-29 05:34:24 UTC (rev 104597)
+++ zope.app.publication/trunk/setup.py	2009-09-29 06:14:18 UTC (rev 104598)
@@ -17,7 +17,7 @@
 # Zope Toolkit policies as described by this documentation.
 ##############################################################################
 
-version = '0'
+version = '3.9.0dev'
 
 import os
 from setuptools import setup, find_packages
@@ -60,6 +60,7 @@
               'zope.app.zptpage',
               'zope.principalregistry',
               'zope.app.applicationcontrol>=3.5.0',
+              'zope.site',
               ]),
     install_requires=['zope.interface',
                       'ZODB3',

Modified: zope.app.publication/trunk/src/zope/app/publication/configure.zcml
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/configure.zcml	2009-09-29 05:34:24 UTC (rev 104597)
+++ zope.app.publication/trunk/src/zope/app/publication/configure.zcml	2009-09-29 06:14:18 UTC (rev 104598)
@@ -1,6 +1,7 @@
 <configure
     xmlns="http://namespaces.zope.org/zope"
     xmlns:browser="http://namespaces.zope.org/browser"
+    xmlns:zcml="http://namespaces.zope.org/zcml"
     >
 
   <adapter
@@ -10,6 +11,19 @@
       permission="zope.Public"
       />
 
+  <subscriber
+      zcml:condition="installed zope.site"
+      for="zope.location.interfaces.ISite
+           zope.app.publication.interfaces.IBeforeTraverseEvent"
+      handler="zope.site.threadSiteSubscriber"
+      />
+
+  <subscriber
+      zcml:condition="installed zope.site"
+      for="zope.app.publication.interfaces.IEndRequestEvent"
+      handler="zope.site.clearThreadSiteSubscriber"
+      />
+
   <view
       for="zope.interface.Interface"
       type="zope.publisher.interfaces.xmlrpc.IXMLRPCRequest"

Added: zope.app.publication/trunk/src/zope/app/publication/site.txt
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/site.txt	                        (rev 0)
+++ zope.app.publication/trunk/src/zope/app/publication/site.txt	2009-09-29 06:14:18 UTC (rev 104598)
@@ -0,0 +1,38 @@
+======================
+Using the site manager
+======================
+
+This test ensures that the site is correctly set and cleared in a thread
+during traversal using event subscribers. Before we start, no site is set:
+
+  >>> from zope.site import hooks
+  >>> hooks.getSite() is None
+  True
+
+  >>> request = object()
+
+  >>> from zope.app.publication import interfaces
+  >>> from zope import site
+
+On the other hand, if a site is traversed,
+
+  >>> from zope.site.tests.test_site import SiteManagerStub, CustomFolder
+  >>> sm = SiteManagerStub()
+  >>> mysite = CustomFolder('mysite')
+  >>> mysite.setSiteManager(sm)
+
+  >>> ev = interfaces.BeforeTraverseEvent(mysite, request)
+  >>> site.threadSiteSubscriber(mysite, ev)
+
+  >>> hooks.getSite()
+  <CustomFolder mysite>
+
+Once the request is completed,
+
+  >>> ev = interfaces.EndRequestEvent(mysite, request)
+  >>> site.clearThreadSiteSubscriber(ev)
+
+the site assignment is cleared again:
+
+  >>> hooks.getSite() is None
+  True


Property changes on: zope.app.publication/trunk/src/zope/app/publication/site.txt
___________________________________________________________________
Added: svn:keywords
   + Id Rev Date
Added: svn:eol-style
   + native

Modified: zope.app.publication/trunk/src/zope/app/publication/tests/test_functional.py
===================================================================
--- zope.app.publication/trunk/src/zope/app/publication/tests/test_functional.py	2009-09-29 05:34:24 UTC (rev 104597)
+++ zope.app.publication/trunk/src/zope/app/publication/tests/test_functional.py	2009-09-29 06:14:18 UTC (rev 104598)
@@ -37,10 +37,14 @@
     httpfactory = functional.FunctionalDocFileSuite(
         '../httpfactory.txt', checker=checker)
     httpfactory.layer = PublicationLayer
+    site = functional.FunctionalDocFileSuite(
+        '../site.txt')
+    site.layer = PublicationLayer
     return unittest.TestSuite((
         notfound,
         methodnotallowed,
         httpfactory,
+        site,
         ))
 
 if __name__ == '__main__':



More information about the checkins mailing list