[Checkins] SVN: gocept.selenium/branches/janjaapdriessen-wsgi/s Base ztk.Layer on wsgi.Layer, use wsgiref instead of zope.server as the HTTP server
Wolfgang Schnerring
wosc at wosc.de
Sat Dec 4 03:58:38 EST 2010
Log message for revision 118697:
Base ztk.Layer on wsgi.Layer, use wsgiref instead of zope.server as the HTTP server
Changed:
U gocept.selenium/branches/janjaapdriessen-wsgi/setup.py
U gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py
-=-
Modified: gocept.selenium/branches/janjaapdriessen-wsgi/setup.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/setup.py 2010-12-04 08:58:15 UTC (rev 118696)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/setup.py 2010-12-04 08:58:37 UTC (rev 118697)
@@ -37,15 +37,19 @@
'setuptools',
],
extras_require=dict(
- grok=['grok',
+ grok=[
+ 'zope.app.appsetup',
'zope.app.publication',
'zope.app.wsgi',
- 'zope.app.appsetup'],
- test_grok=['ZODB3'],
- ztk=['zope.app.server',
+ ],
+ test_grok=[
+ 'grok',
+ 'ZODB3',
+ ],
+ ztk=[
'zope.app.testing',
'zope.app.wsgi',
- 'zope.server'],
+ ],
test_ztk=[
'zope.app.appsetup',
'zope.app.zcmlfiles',
Modified: gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py
===================================================================
--- gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py 2010-12-04 08:58:15 UTC (rev 118696)
+++ gocept.selenium/branches/janjaapdriessen-wsgi/src/gocept/selenium/ztk/__init__.py 2010-12-04 08:58:37 UTC (rev 118697)
@@ -12,41 +12,24 @@
#
##############################################################################
-from zope.server.taskthreads import ThreadedTaskDispatcher
import gocept.selenium.base
-import gocept.selenium.selenese
-import asyncore
-import threading
-import zope.app.server.wsgi
+import gocept.selenium.wsgi
import zope.app.testing.functional
import zope.app.wsgi
-class Layer(gocept.selenium.base.Layer):
+class Layer(gocept.selenium.wsgi.Layer):
- def setUp(self):
- task_dispatcher = ThreadedTaskDispatcher()
- task_dispatcher.setThreadCount(1)
- db = zope.app.testing.functional.FunctionalTestSetup().db
- self.http = zope.app.server.wsgi.http.create(
- 'WSGI-HTTP', task_dispatcher, db, port=self.port)
- self.thread = threading.Thread(target=self.run_server)
- self.thread.setDaemon(True)
- self.thread.start()
- super(Layer, self).setUp()
+ def __init__(self, *bases):
+ # 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 TestCase.setUp()
+ fake_db = object()
+ super(Layer, self).__init__(
+ zope.app.wsgi.WSGIPublisherApplication(fake_db), *bases)
- def tearDown(self):
- self.running = False
- self.thread.join()
- super(Layer, self).tearDown()
- def run_server(self):
- self.running = True
- while self.running:
- asyncore.poll(0.1)
- self.http.close()
-
-
class TestCase(gocept.selenium.base.TestCase,
zope.app.testing.functional.FunctionalTestCase):
# note: MRO requires the gocept.selenium.base.TestCase to come first,
@@ -57,7 +40,6 @@
# DemoStorage (which is set by FunctionalTestCase)
super(TestCase, self).setUp()
db = zope.app.testing.functional.FunctionalTestSetup().db
- application = self.layer.http.application
- assert isinstance(application, zope.app.wsgi.WSGIPublisherApplication)
+ application = self.layer.application
factory = type(application.requestFactory)
application.requestFactory = factory(db)
More information about the checkins
mailing list