Tres Seaver wrote:
After a question on the repoze list about running Zope 2.12.x behind a WSGI server, I went to try that out. I came up with a minimal .wsgi file to run behind mod_wsgi::
$ cat src/Zope2/utilities/skel/bin/zope2.wsgi.in from Zope2.Startup.run import configure from Zope2 import startup configure('<<INSTANCE_HOME>>/etc/zope.conf') startup() # mod_wsgi looks for the special name 'application'. from ZPublisher.WSGIPublisher import publish_module as application
which works, mostly, except that all the App.ImageFile stuff, as well as anything else using IStreamIterator, doesn't. Streaming output also doesn't work: I'm not sure what else.
That's pretty cool. :) I think people will be a bit confused about the relationship between this and repoze.zope2, though. Maybe we can make a statement about how they differ and whether they ought to be consolidated? As for IStreamIterator, I think it should work to just return the iterator as the WSGI body iterator. At least that works in repoze.zope2.
I set out to fix these bugs in ZPublisher.WSGIPublisher.WSGIResponse, and was dismayed to find it an untested hack-up of the original Publish module, with an untested subclass of HTTPResponse, itself almost completely test-free. So I went down the rabbit hole, and got nearly 100% coverage of HTTPResponse on my branch, along with cleaning out some decade-old fossils.
That's really awesome!
Remaining work would be to write tests for WSGIResponse, and then tweak it (and HTTPResponse) to make doing the Right Thing(TM) possible for responses which are more than just a single big string.
Are there any cases other than IStreamIteartor in that case?
Beyond fixing those bugs:
- - Document using Zope2 behind mod_wsgi.
- - Write a function usable as a PasteDeploy app factory, to allow configuration of Zope2 as the endpoint of a pipeline. Document this feature.
- - Supply a stripped-down version of WSGIPublisher, delgating the current implementation's "full stack" behavior (error handling, transaction / retry integration) to middleware. The guts of this can be lifted from repoze.zope2.z2bob. Document using this lighter- weight publisher.
+lots :) Martin -- Author of `Professional Plone Development`, a book for developers who want to work with Plone. See http://martinaspeli.net/plone-book