[Checkins] SVN: gocept.selenium/branches/wosc-zope2-threads/src/gocept/selenium/zope2/__init__.py Get a new ZODB connection per traversal
Wolfgang Schnerring
wosc at wosc.de
Tue Dec 7 09:47:20 EST 2010
Log message for revision 118741:
Get a new ZODB connection per traversal
Changed:
U gocept.selenium/branches/wosc-zope2-threads/src/gocept/selenium/zope2/__init__.py
-=-
Modified: gocept.selenium/branches/wosc-zope2-threads/src/gocept/selenium/zope2/__init__.py
===================================================================
--- gocept.selenium/branches/wosc-zope2-threads/src/gocept/selenium/zope2/__init__.py 2010-12-07 14:46:23 UTC (rev 118740)
+++ gocept.selenium/branches/wosc-zope2-threads/src/gocept/selenium/zope2/__init__.py 2010-12-07 14:47:19 UTC (rev 118741)
@@ -14,7 +14,11 @@
import Lifetime
import Testing.ZopeTestCase
+import Testing.ZopeTestCase.ZopeLite
+import Testing.ZopeTestCase.connections
+import Testing.ZopeTestCase.sandbox
import Testing.ZopeTestCase.utils
+import Zope2
import gocept.selenium.base
import random
import time
@@ -73,3 +77,27 @@
Testing.ZopeTestCase.FunctionalTestCase):
layer = Layer(*BASE_LAYERS)
+
+ def _app(self):
+ # Testing.ZopeTestCase.Sandbox handling of the DemoStorage change is a
+ # little... crude:
+ #
+ # ZApplicationWrapper is instantiated with a DB from
+ # Testing/custom_zodb, but that is never used later on, but Sandbox
+ # passes in the connection (to the current DB) to use instead.
+ # While this is fine for "normal" tests (using testbrowser or whatnot),
+ # this means that there only ever is one single ZODB connection, even
+ # among multiple threads -- which clearly is not what we want.
+ #
+ # Thus, this rewrite of the upstream method, that properly changes the
+ # DB in ZApplicationWrapper, yielding a new connection upon each
+ # traversal.
+ 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()
+ Testing.ZopeTestCase.sandbox.AppZapper().set(app)
+ app = Testing.ZopeTestCase.utils.makerequest(app)
+ Testing.ZopeTestCase.connections.register(app)
+ return app
More information about the checkins
mailing list