[Checkins] SVN: gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/ Fix ZODB connection setup for the Zope2 flavour (re #6488)
Wolfgang Schnerring
wosc at wosc.de
Sat Dec 25 09:38:51 EST 2010
Log message for revision 119084:
Fix ZODB connection setup for the Zope2 flavour (re #6488)
Changed:
U gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py
U gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py
-=-
Modified: gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py
===================================================================
--- gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py 2010-12-25 14:37:46 UTC (rev 119083)
+++ gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/__init__.py 2010-12-25 14:38:51 UTC (rev 119084)
@@ -56,3 +56,33 @@
Testing.ZopeTestCase.FunctionalTestCase):
layer = Layer(*BASE_LAYERS)
+
+ def _app(self):
+ # Testing.ZopeTestCase.sandbox.Sandbox swapping of the DemoStorage is a
+ # little... crude:
+ #
+ # ZApplicationWrapper is instantiated with a DB from
+ # Testing/custom_zodb, which is never used later on, since Sandbox
+ # passes in the connection (to the current DB) to use instead. This
+ # connection is also stored globally in
+ # Testing.ZopeTestCase.sandbox.AppZapper (and passed to requests via
+ # the bobo_traverse monkey-patch there) -- which means that there only
+ # ever is one single ZODB connection, among the test code and the HTTP
+ # requests, and among concurrent requests. This clearly is not what we
+ # want.
+ #
+ # Thus, this rewrite of the upstream method, that properly changes the
+ # DB in ZApplicationWrapper and does *not* use AppZapper, yielding a
+ # new connection upon each traversal. (For reference and since it took
+ # me quite a while to figure out where everything is: this code is
+ # adapted from the original Sandbox._app and the normal Zope2 startup
+ # in Zope2.__init__).
+
+ Zope2.startup()
+ db, aname, version = Zope2.bobo_application._stuff
+ db = Testing.ZopeTestCase.ZopeLite.sandbox()
+ Zope2.bobo_application._stuff = db, aname, version
+ app = Zope2.bobo_application()
+ app = Testing.ZopeTestCase.utils.makerequest(app)
+ Testing.ZopeTestCase.connections.register(app)
+ return app
Modified: gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py
===================================================================
--- gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py 2010-12-25 14:37:46 UTC (rev 119083)
+++ gocept.selenium/branches/wosc-zodb-isolation/src/gocept/selenium/zope2/tests/zope210/test_zope210.py 2010-12-25 14:38:51 UTC (rev 119084)
@@ -12,18 +12,25 @@
#
##############################################################################
+import Testing.ZopeTestCase
+import Zope2
+import gocept.selenium.tests.isolation
+import gocept.selenium.zope2
import unittest
-import gocept.selenium.zope2
-import gocept.selenium.tests.isolation
-import Testing.ZopeTestCase
Testing.ZopeTestCase.installProduct('Five')
class Zope2Tests(gocept.selenium.tests.isolation.IsolationTests,
gocept.selenium.zope2.TestCase):
- pass
+ def getRootFolder(self):
+ return self.app
+ def getDatabase(self):
+ db, aname, version = Zope2.bobo_application._stuff
+ return db
+
+
def test_suite():
return unittest.makeSuite(Zope2Tests)
More information about the checkins
mailing list