[Zope-Checkins] SVN: Zope/branches/tseaver-fix_wsgi/src/ZPublisher/ fixed setDefaultSkin not being added to request and added tests for it
Nathan Van Gheem
vangheem at gmail.com
Sun May 30 12:32:54 EDT 2010
Log message for revision 112852:
fixed setDefaultSkin not being added to request and added tests for it
Changed:
U Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py
U Zope/branches/tseaver-fix_wsgi/src/ZPublisher/tests/test_WSGIPublisher.py
-=-
Modified: Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py
===================================================================
--- Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py 2010-05-30 15:34:02 UTC (rev 112851)
+++ Zope/branches/tseaver-fix_wsgi/src/ZPublisher/WSGIPublisher.py 2010-05-30 16:32:54 UTC (rev 112852)
@@ -22,6 +22,10 @@
from ZPublisher.HTTPResponse import HTTPResponse
from ZPublisher.HTTPRequest import HTTPRequest
+
+from zope.publisher.interfaces import ISkinnable
+from zope.publisher.skinnable import setDefaultSkin
+
from ZPublisher.mapply import mapply
from ZPublisher.pubevents import PubBeforeStreaming
from ZPublisher.Publish import call_object
@@ -141,7 +145,6 @@
raise NotImplementedError
def publish(request, module_name, after_list, debug=0):
-
(bobo_before,
bobo_after,
object,
@@ -171,7 +174,6 @@
path = request.get('PATH_INFO')
request['PARENTS'] = parents = [object]
-
object = request.traverse(path, validated_hook=validated_hook)
if transactions_manager:
@@ -194,7 +196,6 @@
return response
def publish_module(environ, start_response):
-
status = 200
after_list = [None]
stdout = StringIO()
@@ -205,7 +206,9 @@
response._server_version = environ.get('SERVER_SOFTWARE')
request = HTTPRequest(environ['wsgi.input'], environ, response)
-
+ if ISkinnable.providedBy(request):
+ setDefaultSkin(request)
+
# Let's support post-mortem debugging
handle_errors = environ.get('wsgi.handleErrors', True)
Modified: Zope/branches/tseaver-fix_wsgi/src/ZPublisher/tests/test_WSGIPublisher.py
===================================================================
--- Zope/branches/tseaver-fix_wsgi/src/ZPublisher/tests/test_WSGIPublisher.py 2010-05-30 15:34:02 UTC (rev 112851)
+++ Zope/branches/tseaver-fix_wsgi/src/ZPublisher/tests/test_WSGIPublisher.py 2010-05-30 16:32:54 UTC (rev 112852)
@@ -154,7 +154,89 @@
self.assertRaises(NotImplementedError, lambda: str(response))
+def noopStartResponse(status, headers):
+ pass
+
+
+class WSGIPublisherTests(unittest.TestCase):
+ _dummy_interface = None
+
+ def setUp(self):
+ from zope.testing.cleanup import cleanUp
+
+ cleanUp()
+ self._registerAdapters()
+
+ def _dummyInterface(self):
+ from zope.interface import Interface
+ if self._dummy_interface is not None:
+ return self._dummy_interface
+
+ class IDummy(Interface):
+ """IDummy"""
+
+ self._dummy_interface = IDummy
+ return IDummy
+
+ def _registerAdapters(self):
+ from Acquisition import Implicit
+ from zope.component import getGlobalSiteManager
+ from zope.interface import Interface
+ from zope.publisher.browser import BrowserPage
+ from zope.publisher.browser import IDefaultBrowserLayer
+ from zope.traversing.interfaces import ITraversable
+ from zope.traversing.namespace import view
+ from OFS.interfaces import IApplication
+
+ gsm = getGlobalSiteManager()
+
+ IDummy = self._dummyInterface()
+
+ class TestPage(BrowserPage):
+ __name__ = 'testing'
+ def __call__(self):
+ return 'foobar'
+
+ # Define the views
+ gsm.registerAdapter(TestPage, (IApplication, IDefaultBrowserLayer),
+ Interface, 'testing')
+
+ # Bind the 'view' namespace (for @@ traversal)
+ gsm.registerAdapter(view,
+ (IApplication, IDefaultBrowserLayer),
+ ITraversable, 'view')
+
+ def test_publish_module_uses_setDefaultSkin(self):
+ from StringIO import StringIO
+
+ self._registerAdapters()
+ environ = {
+ 'SCRIPT_NAME' : '',
+ 'PATH_INFO' : '/@@testing',
+ 'REQUEST_METHOD' : 'GET',
+ 'QUERY_STRING' : '',
+ 'SERVER_NAME' : '127.0.0.1',
+ 'REMOTE_ADDR': '127.0.0.1',
+ 'wsgi.url_scheme': 'http',
+ 'SERVER_PORT': '80',
+ 'HTTP_HOST': '127.0.0.1:80',
+ 'SERVER_PROTOCOL' : 'HTTP/1.1',
+ 'wsgi.input' : StringIO(''),
+ 'CONTENT_LENGTH': '0',
+ 'HTTP_CONNECTION': 'keep-alive',
+ 'CONTENT_TYPE': ''
+ }
+
+ from ZPublisher.WSGIPublisher import publish_module
+ self.failUnless(publish_module(environ, noopStartResponse) == ('', 'foobar'))
+
+
def test_suite():
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(WSGIResponseTests))
+ suite.addTest(unittest.makeSuite(WSGIResponseTests, 'test'))
+ suite.addTest(unittest.makeSuite(WSGIPublisherTests, 'test'))
return suite
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
+
\ No newline at end of file
More information about the Zope-Checkins
mailing list