[Checkins] SVN: gocept.selenium/branches/janjaapdriessen-wsgi/s Port application setup from ztk.Layer to grok.Layer to reduce coupling

Wolfgang Schnerring wosc at wosc.de
Sat Dec 4 04:14:19 EST 2010


Log message for revision 118698:
  Port application setup from ztk.Layer to grok.Layer to reduce coupling
  to zope.app.wsgi: take the request factory class from there instead of hard-coding it here.
  

Changed:
  U   gocept.selenium/branches/janjaapdriessen-wsgi/setup.py
  U   gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py

-=-
Modified: gocept.selenium/branches/janjaapdriessen-wsgi/setup.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/setup.py	2010-12-04 08:58:37 UTC (rev 118697)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/setup.py	2010-12-04 09:14:18 UTC (rev 118698)
@@ -39,7 +39,6 @@
     extras_require=dict(
         grok=[
             'zope.app.appsetup',
-            'zope.app.publication',
             'zope.app.wsgi',
             ],
         test_grok=[

Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py	2010-12-04 08:58:37 UTC (rev 118697)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/grok/__init__.py	2010-12-04 09:14:18 UTC (rev 118698)
@@ -14,8 +14,7 @@
 import unittest
 
 from zope.app.appsetup.testlayer import ZODBLayer
-from zope.app.wsgi import WSGIPublisherApplication
-from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
+import zope.app.wsgi
 
 import gocept.selenium.selenese
 import gocept.selenium.wsgi
@@ -23,7 +22,15 @@
 
 class Layer(ZODBLayer, gocept.selenium.wsgi.Layer):
 
-    application = WSGIPublisherApplication()
+    def __init__(self, *args):
+        # since the request factory class is only a parameter default of
+        # WSGIPublisherApplication and not easily accessible otherwise, we fake
+        # it into creating a requestFactory instance, so we can read the class
+        # off of that in testSetUp()
+        fake_db = object()
+        gocept.selenium.wsgi.Layer.__init__(
+            self, zope.app.wsgi.WSGIPublisherApplication(fake_db))
+        ZODBLayer.__init__(self, *args)
 
     def setUp(self):
         ZODBLayer.setUp(self)
@@ -37,8 +44,8 @@
         # A fresh database is created in the setup of the ZODBLayer:
         ZODBLayer.testSetUp(self)
         # We tell the publisher to use this new database:
-        self.application.requestFactory = \
-            HTTPPublicationRequestFactory(self.db)
+        factory = type(self.application.requestFactory)
+        self.application.requestFactory = factory(self.db)
 
 
 class TestCase(unittest.TestCase):



More information about the checkins mailing list