[mod_python] mptest.py works, other .py files don't

Daniel Popowich dpopowich at comcast.net
Thu Jan 20 09:10:08 EST 2005


> What you need, therefore, is a dispatching handler function, which
> knows where to find the code for the various pages of your
> application. That's what you get with the builtin mod_python.publisher
> handler (which is described in the documentation), or other handlers,
> like the one provided by spin-off projects like mod_python servlets
> (MPS), Vampire, etc.

Yes, there does seem to be a need for a central dispatching function:
just look at the preponderance of solutions, as you state.  Other
anecdotal evidence is the number of questions regarding "how do I
import..." and "what's my cwd" on this list.

When writing mpservlets I wanted to use SetHandler for whole
directory hierarchies, but immediately ran into trouble with
importing servlet code.  That's when I brewed my own solution: create
a cache, "full path of filename"=>"code object", using the pyhton
builtin function, execfile, to create the code object.  Subsequent
requests for the same servlet grab it from the cache.

Could there be a meeting of the minds, as it were, and develop a
common function to meet the needs of many, if not all?

Meanwhile...if you're looking for a handler that has one solution to
this problem and if you want to code your pages using OO techniques,
take a look at mod_python servlets (mpservlets).  Link below.  There's
a link on the homepage to a live tutorial where you can view the
source as you go.  The tutorial is included in the download, too.

Cheers,

Daniel Popowich
-----------------------------------------------
http://home.comcast.net/~d.popowich/mpservlets/


More information about the Mod_python mailing list