[Zope-dev] Zope2 and WSGI
Tres Seaver
tseaver at palladion.com
Tue Dec 22 23:52:16 EST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin Aspeli wrote:
> 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?
repoze.zope2 was written to get pre-eggified, pre-WSGI-aware Zope
(<=2.11.x) deployable using eggs and Paste. 2.12 is eggified, and
speaks a kind of pidgin WSGI; repoze.zope2 is likely still useful,
becuase it is more "fluent" in WSGI. See below for futures.
> 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?
response.write() is the other one I know about. Getting it to do the
Right Thing(TM) under WSGI is going to be tricky, I think.
>> 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.
If it gets that far by Zope 2.13, then we can likely retire repoze.zope2.
Trs.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAksxogAACgkQ+gerLs4ltQ5A1QCgnMpbgP926y5S/vnq6tsht8Tt
Lw0An0/MvmhLMF3gJTL6f4wp2hL9gfXV
=EKW6
-----END PGP SIGNATURE-----
More information about the Zope-Dev
mailing list