Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 5 (modified by anonymous, 13 years ago) (diff)


Turbogears 0.9-prerelease mod_python integration

The SVN version of TG uses cherrypy-2.2.0-beta which, AFAIK, is not compatible with the mpcp script described at the other modpy integration page.

I've managed to get it running using Robert Brewer's It has been tested on a Debian Sarge box, Apache 2.0.54 and a backported libapache2-mod-python2.4 package from Ubuntu (the package didn't install cleanly and some black drudgery had to be done to get it working by hand so I will not post it here yet, if there's some demand I might try to build a better backport). However, provided you can run your TG app with python2.3, you should be fine with Sarge's stock modpytyhon2.3. (I'm a big fan of 2.4's syntax sugar so I couldn't resist :)

Here is a quick recipe:

  • Install wsigiref, sudo easy_install wsgiref should get you going.
  • Download Robert's  script and place it inside wsgiref's package.
  • You'll need to write a script to start your TG app as will not work. It should be something like:
import pkg_resources

import cherrypy
import turbogears


from yourapp.controllers import Root

cherrypy.root = Root()
cherrypy.server.start(initOnly=True, serverClass=None)                                                 

Make sure you don't make any reference to sys.argv (as modpython doesn't have a command line) and you use full paths (as Apache's working directory is /, like any well behaved unix daemon...). Don't forget to fix your paths and application name!.

Place this script in your application's package (where lives)

  • Now you should sudo python install your app, you can get away by sudo python develop it. But then you should make your application's directory writable by your Apache user (normally www-data) which you should by no means do on a production box (if you can't guess why, then you should not be running a production box ;)

More to come when I finish my dinner ;)