[mod_python] Unable to import modules in subdirs

Brandon N woodsman at gmail.com
Thu Oct 27 21:05:44 EDT 2005

I've checked out Vampire, and it would seem to be exactly that which I
desire (after only a few minutes of experimentation at least). Does one
typically include their .py files with this setup in the public directory
(with indexing and such disabled, naturally)? Or is there a way to reference
files outside of the public system?

Thanks to the both of you with your help. It's cleared up a great deal for


On 10/27/05, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> Jorey Bump wrote ..
> > Brandon N wrote:
> > > A) Is it requestHandler's job to determine which file was requested
> and
> > > respond accordingly (via the request's .filename?) with a switch
> > > construct or equivalent?
> >
> > Yes and no. Apache's already passed the file to the handler based on its
> > extension, presence in a directory, or other criteria. The developer of
> > the handler gets to decide what the handler does with *whatever* is
> > passed to it. Some assume it will contain only valid Python code and
> > process it as such (mod_python.publisher, for example). Some might want
> > to process proprietary or other file formats using python (you might
> > make a handler to display Word files, for example), but remain agnostic
> > about the actual filename or extension. But there's no reason why your
> > handler can't branch according to the file extension (which is what
> > Graham's Vampire does, if I'm not mistaken).
> If you are coming from a PHP background where each URL essentially
> maps to a distinct file, Vampire may well be a good starting point as it
> works in a similar way at it most basic level.
> Thus, where in PHP you might have:
> index.php # URL -> /index.php
> search.php # URL -> /search.php
> Vampire would similarly have separate files for each resource, although
> in Vampire it is the name of the handler within the file which dictates
> what extension the URL needs to have:
> index.py
> def handler(req): ... # /index
> def handler_html(req): ... # /index.html
> def handler_php(req): ... # /index.php (Yes, pretend we are PHP when we
> aren't).
> search.py
> def handler(req): ... # /search
> def handler_html(req): ... # /search.html
> Thus, if you want to write your code in the form of basic handlers but a
> distinct handler for each resource, the basic dispatch mechanism of
> Vampire is going to allow you to get started quicker.
> Another alternative as Jorey pointed out is mod_python.publisher,
> however it doesn't allow you to as easily dictate use of multiple
> different extension types used on URLs nor is it necessarily as easy to
> mix static files in the same directory.
> For a further basic introduction to Vampire, see:
> http://www.dscpl.com.au/projects/vampire/articles/vampire-001.html
> Graham
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051027/56cf8ac5/attachment.html

More information about the Mod_python mailing list