ó
»ÏâIc @ sË d Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m Z d „ Z d d d „ ƒ YZ
e Z e a
d „ Z e d „ Z d d l Z d d l Z d
d „ Z d e f d
„ ƒ YZ d S( sI Native adapter for serving CherryPy via mod_python
Basic usage:
##########################################
# Application in a module called myapp.py
##########################################
import cherrypy
class Root:
@cherrypy.expose
def index(self):
return 'Hi there, Ho there, Hey there'
# We will use this method from the mod_python configuration
# as the entry point to our application
def setup_server():
cherrypy.tree.mount(Root())
cherrypy.config.update({'environment': 'production',
'log.screen': False,
'show_tracebacks': False})
##########################################
# mod_python settings for apache2
# This should reside in your httpd.conf
# or a file that will be loaded at
# apache startup
##########################################
# Start
DocumentRoot "/"
Listen 8080
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
PythonPath "sys.path+['/path/to/my/application']"
SetHandler python-program
PythonHandler cherrypy._cpmodpy::handler
PythonOption cherrypy.setup myapp::setup_server
PythonDebug On
# End
The actual path to your mod_python.so is dependent on your
environment. In this case we suppose a global mod_python
installation on a Linux distribution such as Ubuntu.
We do set the PythonPath configuration setting so that
your application can be found by from the user running
the apache2 instance. Of course if your application
resides in the global site-package this won't be needed.
Then restart apache2 and access http://127.0.0.1:8080
iÿÿÿÿN( t
format_exct
bare_error( t httpc s² d d l m ‰ ˆ j ƒ } d | k r² | d j d d ƒ } t | ƒ d k ro t | d t ƒ t ƒ ƒ } q² | \ } } t | t ƒ t ƒ | g ƒ } t | | ƒ } | ƒ n t j
j i t d 6t
d 6d g d
6ƒ t j ‰ t ˆ d ƒ rˆ j j ƒ n t ˆ d ƒ r!ˆ j j ƒ n ˆ j j ƒ t j j ƒ ‡ ‡ f d
† } ˆ j d | ƒ ˆ j ƒ ‡ f d † } y ˆ j | ƒ Wn$ t k
rˆ j j ˆ | ƒ n Xd S( Niÿÿÿÿ( t apaches cherrypy.setups ::i i s
log.screens tools.ignore_headers.ont Ranges tools.ignore_headers.headerst signal_handlert console_control_handlerc st ˆ j } t j | k r$ ˆ j } n6 t j | k r? ˆ j } n t j | k rZ ˆ j } n ˆ j | | ˆ j ƒ d S( N(
t APLOG_ERRt loggingt DEBUGt APLOG_DEBUGt INFOt
APLOG_INFOt WARNINGt
APLOG_WARNINGt log_errort server( t msgt levelt newlevel( R t req( s7 /usr/lib/python2.7/vendor-packages/cherrypy/_cpmodpy.pyt _logc s t logc s ˆ j ƒ d S( N( t exit( t data( t engine( s7 /usr/lib/python2.7/vendor-packages/cherrypy/_cpmodpy.pyt cherrypy_cleanups s ( t
mod_pythonR t get_optionst splitt lent
__import__t globalst localst getattrt cherrypyt configt updatet Falset TrueR t hasattrR t unsubscribeR t
autoreloadR t subscribet startt register_cleanupt AttributeError( R t optionst atomst modt modnamet fnamet funcR R ( ( R R R s7 /usr/lib/python2.7/vendor-packages/cherrypy/_cpmodpy.pyt setupG s8
t _ReadOnlyRequestc B s e Z d Z d „ Z RS( t readt readlinet readlinesc C s. x' | j D] } t | | ƒ | j |