Howdy,
I've been writing a little CherryPy based application for
the last year
or so. Its received a moderate amount of usage and most of
the users of
the software are not programmers. They're fine with setting
up Apache
for proxying the requests through to the cherrypy server,
and can manage
their way through a cherrypy configuration file, but they'd
rather not
touch the code of the actual application.
Recently the codebase was upgraded to support CherryPy 3.0
and I've been
trying to make it so in addition to running as an
independent web
server, it also can run under mod_python. Normally to run
the
application on uses:
python myapp.py -c CONFIGURATIONFILE
Or, they just call their configuration file default.conf and
it reads in
the configuration automatically. I'd like to find a way to
do something
similar to passing this command line argument using
mod_python and cherrypy.
Here's a snippet of what the configuration in httpd.conf may
look like:
<Location "/gal2">
PythonPath
"sys.path+['/home/patrick/pennave/src']"
SetHandler python-program
PythonHandler cherrypy._cpmodpy::handler
PythonOption cherrypy.setup
myapp::setup_server
PythonDebug On
</Location>
In a CGI environment, I could use the SetEnv directive for
apache to set
environment variables and then have the application use
os.getenv to
read the variable back. But mod_python doesn't handle
environment
variables.
The mod_python way is to use "PythonOption", which
then allows you to
get all the PythonOption declarations using
req.get_options(). Which is
fine in most cases, but again, I can't get access to this
because
setup_server is called with no arguments and as near as I
can tell,
_cpmodpy.py doesn't do anything to pass that through.
There's a
roundabout way to get access to part of the req object
through the
cherrypy.request.rfile object, but alas, this does not
expose the
get_options method.
While it's simple enough for me to modify cpmodpy.py to
allow for
get_options on the req object, I'd rather find a way to pass
this
information without requiring my users to modify their
CherryPy
installations.
Any hints?
Thanks!
--Patrick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|