Follow us on Twitter
Latest Tweet: New blog post on raw roles allowing arbitrary html in docutils < 0.6 http://blog.projectfondue.com/2010/7/27/security-raw-roles-in-docutils
L'Alpiniste

The blog of the Project Fondue Team

Using Apache in a Python Development Environment

written by Stuart Colville, on 12 July, 2010 at 21:52

Making a development environment as close to the what's used in production is always a good plan, as it helps to catch issues earlier as you develop. The following details the way we are using apache in the development of a current side-project.

http://pf.staticfil.es/blog/images/apache-dev.png

figure 1: Apache front-end and two web services.

Initially our development environment used the built-in WSGI server that comes with Werkzeug, but it occurred to me that ultimately this would be running on mod_wsgi under apache, so we decided to set-up the development environment to use apache instances with mod_wsgi running in daemon mode.

This actually proved to be fairly straight forward, all that's required is to generate a configuration for each instance at run-time, which points at each application.

By abstracting the start-up of each instance a single script can fire up the web-services, and additionally the front-end one after the other. The other advantage with this approach is that you can then develop any configurations that make use of apache modules with ease, so for example using something like mod_rewrite is no problem. In essence this means you don't have to write utility code that's just used to replicate something that your server provides.

Reloading on changes. Development servers such as Werkzeug's come with code to trigger a reload when code changes so that you can see changes instantly during development. Fortunately with mod_wsgi this isn't a problem as the code is provided for you see the mod_wsgi documentation.

Configuring this as part of the environment is simple and works very well.

All of this means you can have a development evnironment that brings you closer to a production environment with minimal hassle. So far this is working very well for us.

Leave a Reply: