Chapter 18.3.2. Configuring Apache/CherryPy for mod_python
The recommended way to run CherryPy with mod_python is to use the mpcp module available from http://jamwt.com/. The following configuration example applies to Apache 2.0, mod_python 3, Python 2.4, and CherryPy 2.2. Here is how you configure Apache:
ServerName 'cherrypy.example.com' PythonPath "['/path/to/project-root'] + sys.path' <Location "/"> SetHandler mod_python PythonHandler mpcp PythonOption cherrysetup control.main.root::mp_setup </Location>
And here is sample code showing how to set up CherryPy for mod_python:
import cherrypy class CherryApp: @cherrypy.expose def index(self, **kwargs): return 'Hello, World!' cherrypy.root = CherryApp() if __name__ == '__main__': # CP server ...
Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.