[mod_python] psp module

Graham Dumpleton grahamd at dscpl.com.au
Wed May 25 18:27:01 EDT 2005


On 25/05/2005, at 11:02 PM, eoghan wrote:

> Will take a look at that. On a different slant, the testing page in 
> the docs refers to adding apache directives to the conf or .htaccess. 
> Im just wondering, if I have 5 .py files in my /test/ dir, how do i 
> tell it to parse all of them as python? So if i had, mptest.py and 
> hello.py in my dir do i say:
> AddHandler mod_python .py
> PythonHandler mptest, hello
> PythonDebug On
>
> Or is there a way just to allow all files in this path to be parsed?

Using the configuration above, for any URL accessing that directory 
which
ends in a ".py" extension, the handler() method on mptest.py will first
be called. This would result in headers being returned along with 
whatever
content it wrote to the req object. If that handler returns apache.OK,
then the hello.py handler() method will be called and any content it
generates will be appended to that already produced by the handler in
mptest.py.

I am guess that this probably isn't what you want as for most people it
isn't. If what you are actually after is that if a URL with "mptest" in
it is used then you want "mptest.py" handler to be used. If a URL with
"hello" in it is used you want "hello.py" handler to be used. If this is
the case then go and look at Vampire.

   http://www.dscpl.com.au/projects/vampire

It implements a dispatcher which will map requests against different
resources to different handlers.

If you are intending to only use PSP and you don't actually need to be
doing any before its use, you could also just use mod_python.psp as
the handler as documentation describes. If you do need to do a bit
extra setup before invoking PSP but it is always the same, there are
ways with Vampire of specifying a default handler to do it. Eg.

   http://svn.dscpl.com.au/vampire/trunk/examples/psp/
   http://svn.dscpl.com.au/vampire/trunk/examples/psp/_handler.py

You might have to view source as browsers stuff up indenting a bit when
accessed from repository in this way.

Note that the example referenced here has been extended greatly from
the same PSP example in the latest official Vampire tar ball. Newer
version can be obtained direct from source code repository if needed.

Graham




More information about the Mod_python mailing list