Zope3 and WSGI integration
Zope3 app server now provides a WSGI application object (see zope.app.wsgi for details on its implementation) which can be easily integrated with existing WSGI servers.
Let's take for example wsgiref - the WSGI server reference implementation - and combine it with an existing Zope3 checkout (you will need to adjust the setup when running from an instance*).
You start by modifying the zope.conf file into zope.wsgi.conf:
--- file: zope.wsgi.conf ---
site-definition site.zcml <zodb> <filestorage> path DataWSGI.fs </filestorage> </zodb> <eventlog> <logfile> path STDOUT </logfile> </eventlog> devmode on
You could have changed the site.zcml file too, but keep it unchanged for simplicity. The example configuration works from its own ZODB storage, defines no servers, logs to stdout and has devmode set to on (default is off with recent releases).
You also need a script start_wsgi.py to start the WSGI server and pass it the WSGI app object:
--- file: start_wsgi.py ---
from zope.app import wsgi from cStringIO import StringIO configFile=StringIO(open('zope.wsgi.conf').read()) app=wsgi.getWSGIApplication(configFile) from wsgiref import simple_server from wsgiref.validate import validator httpd=simple_server.make_server('',8080,validator(app)) httpd.serve_forever()
This loads the zope.wsgi config file, creates the zope WSGI app object, starts a WSGI server on port 8080 serving the WSGI app.
To run it in a shell you first set the python environment, then start the server:
--- shell ---user@host: export PYTHONPATH=/home/user/Zope3/src user@host: python2.4 start_wsgi.py
That's it - really.
Point our browser to http://localhost:8080/ and use as always. To shutdown the server and terminate the script simply press CTRL-D.
Update: a year later i think this was just a nice try -- what you really want to use right now is zopeproject (Zope3 integrated with Python Paste WSGI Toolkit): gets you a very easy start and pleasant development experience.
Comment
I've created a collection of support files to help with this issue: check http://trac.d2m.at/d2m/browser/Zope3/zope3wsgi/ for more information.
Comment
While reading src/zope/app/apidoc/bookmodule/book.zcml an Exception is thrown in <configure package="zope.testbrowser"> ... </configure> and for some reason unittests are executed...
Commenting out the configure directive solves the problem atm.


Comment
import os os.chdir(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'etc'))