[mod_python] Flexible imports

Colin Fox cfox at cfconsulting.ca
Sun Mar 7 19:46:18 EST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ron Alford wrote:
| Colin Fox wrote:
|
|> Here's my .htaccess file:
|>
|> DirectoryIndex index.xml index.html index.py
|> AddHandler python-program .xml .py
|> PythonHandler xml_handler
|> PythonDebug on
|> PythonAutoReload on
|>
|
| You're setting the PythonHandler for everything with that line
| I believe the syntax for PythonHandler in this case is
| PythonHandler xml_handler | .xml
| PythonHandler foo_handler | .py

Thanks! That works beautifully.

Now I've run into a slightly different quandry. Using the above note, I
can now process XML files via my single XML handler, and python files
wherever they are. That's great.

I only need one last thing for this to be all perfect - I need a
lower-level access to the req object. When the python file indicated in
the URL is called, any form data is already processed into a
FieldStorage object.

I have a different format that I use and would prefer to process it
myself. I can use the FieldStorage, but it's a waste of cycles to
process input into FieldStorage objects just to pull the info right back
out into something else. I just need the raw data, straight from the req
object.

Also, the return value of the python function is apparently a print
statement or something. What I would like would be to handle all the
processing, and perhaps even execute internal or external redirects,
which doesn't seem to be possible or practical if I'm to return a string.

If I write my own publisher, I get a raw req object, and I can return
various apache error codes. Is there a way to get this lower-level
access to both the input and output of the request handling?

Thanks,
~   cf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAS+yKoaQ1/feGlJoRAqkUAJ0SVXH4LmeTpTnP/bCDjNw92t1jfgCffD3t
Au5e9uiSC62ySZoYaegxj90=
=FeDg
-----END PGP SIGNATURE-----


More information about the Mod_python mailing list