This post originated from an RSS feed registered with Python Buzz
by Carlos de la Guardia.
Original Post: Repoze: Me grok speak WSGI
Feed Title: I blog therefore I am
Feed URL: http://blog.delaguardia.com.mx/feed.atom
Feed Description: A space to put my thoughts into writing.
I think Repoze is a potentially great thing for the Zope world, so I've been experimenting with getting different Repoze projects running under mod_wsgi and apache, which I think may become the standard deployment solution for production Python WSGI apps.
Grok is nearing a 1.0 release and is a web development framework which makes the following claims:
Easy to use.
For Python developers.
Powerful.
Based on Zope 3 technologies.
For those of you that will immediately jump and say that claim number four is incompatible with one and two above, please at least visit Grok's web site and give it a try. We are really talking about a Python web development framework here.
Getting Grok to run under mod_wsgi is very easy, but as of this writing you will need to check out repoze.grok from the subversion trunk, since it contains fixes to make the WSGI setup work using the included sample files instead of rolling your own.
Once you have the correct version, setting it up is very straightforward. Install mod_wsgi under Apache and make sure you have a Python 2.4 installation ready with setuptools already installed. Check my post on Plone behind mod_wsgi if you need more detailed instructions for this.
Repoze uses virtualenv to create sandboxes for the applications it runs, so that each one has an independent Python environment of its own and avoids egg conflicts with other applications. To create the Grok sandbox:
Now all you need to do is copy the contents of the apache2.conf file from the etc directory in your sandbox into your Apache configuration (with the appropiate editsfor your site, of course) and rename the sample-users.zcml file in the same directory to users.zcml (or create you own) and Grok is ready to run.
Since this configuration is intended for production use, you will also need to setup a ZEO server and configure the zope process to connect to it. Just run 'bin/mkzeoinstance .' from your sandbox directory and add the required configuration to the zope.conf file. Here is an example:
<zodb_db main> cache-size 5000 <zeoclient> server localhost:8100 storage 1 cache-size 20MB name zeostorage var $INSTANCE/var </zeoclient> mount-point / </zodb_db>
That's all there is to it, you can now run Grok behind mod_wsgi by restarting the ZEO and Apache processes:
$ bin/zeoctl start
$ sudo apache2ctl start
You Grok application is ready to run under mod_wsgi, and perhaps be combined with other Python WSGI applications on the same site.