[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/session/ftests.py Fix the functional to only access the session on traversing the root folder; later session access defeats the purpose of the tests. The old version wouldn't fail if the new event code is disabled.

Martijn Pieters mj at zopatista.com
Thu Aug 3 09:35:18 EDT 2006


Log message for revision 69342:
  Fix the functional to only access the session on traversing the root folder; later session access defeats the purpose of the tests. The old version wouldn't fail if the new event code is disabled.

Changed:
  U   Zope3/trunk/src/zope/app/session/ftests.py

-=-
Modified: Zope3/trunk/src/zope/app/session/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/session/ftests.py	2006-08-03 02:11:19 UTC (rev 69341)
+++ Zope3/trunk/src/zope/app/session/ftests.py	2006-08-03 13:35:16 UTC (rev 69342)
@@ -18,6 +18,7 @@
 import unittest
 from zope.component import provideHandler, getGlobalSiteManager
 from zope.app.folder import Folder
+from zope.app.folder.interfaces import IRootFolder
 from zope.app.publication.interfaces import IBeforeTraverseEvent
 from zope.app.testing.functional import BrowserTestCase
 from zope.app.zptpage.zptpage import ZPTPage
@@ -67,22 +68,23 @@
     def setUp(self):
         super(VirtualHostSessionTest, self).setUp()
         page = ZPTPage()
-        page.source = (u'<div '
-                       u'tal:define="session request/session:products.foo"/>')
+        page.source = u'<div>Foo</div>'
         page.evaluateInlineCode = True
         root = self.getRootFolder()
         root['folder'] = Folder()
         root['folder']['page'] = page
         self.commit()
         
-        provideHandler(self.accessSessionOnTraverse, (IBeforeTraverseEvent,))
+        provideHandler(self.accessSessionOnRootTraverse, 
+                       (IBeforeTraverseEvent,))
         
     def tearDown(self):
-        getGlobalSiteManager().unregisterHandler(self.accessSessionOnTraverse,
-                                                 (IBeforeTraverseEvent,))
+        getGlobalSiteManager().unregisterHandler(
+            self.accessSessionOnRootTraverse, (IBeforeTraverseEvent,))
         
-    def accessSessionOnTraverse(self, event):
-        session = ISession(event.request)
+    def accessSessionOnRootTraverse(self, event):
+        if IRootFolder.providedBy(event.object):
+            session = ISession(event.request)
         
     def assertCookiePath(self, path):
         cookie = self.cookies.values()[0]



More information about the Zope3-Checkins mailing list