[mod_python] handling virtual files

Graham Dumpleton grahamd at dscpl.com.au
Fri Jul 15 19:49:42 EDT 2005

On 16/07/2005, at 9:15 AM, Alejandro Mery wrote:

> Hi, i need some directions :-)
> i need to have 'virtual' and real files on a tree, virtual paths have 
> a folder on the root which somehow gets the next folder, and again and 
> again. mixing different methods. /dir1/dir2/dir3/dir4/file
> dir1 is simply a folder, dir2 is 'mounted' for a database, where dir3 
> is  simply a folder, and dir4 is a 'COW' (copy on write) of another 
> directory.
> i get the file into temporal location and now i call the file handler 
> over the temporal location but thinking its on the virtual one.
> but req.filename is read-only.. how should i solve this problem? what 
> do you recommend?

In mod_python 3.X, req.filename can be modified. It was read only
in mod_python 2.7 though.

What base handler were you thinking of using, were you thinking
of starting with something like mod_python.publisher or writing
your own handlers from scratch?

In respect of req.filename, its use becomes limited in a system
where you have virtual directory concepts, or where you want to
store the physical files somewhere else besides the actual document
tree and have a proxy handler which serves them up. This is because
req.filename is set based on what physical files Apache is able
to identify and thus if the files are elsewhere or map to a virtual
resource, it by itself doesn't help much. Thus, you still need to
go off and do your own interpretation of req.path_info to identify
the actual virtual resource.

Anyway, that you feel you need to modify req.filename sounds like
you have in mind a scheme like the WSGI middlware stack where
middlware components can modify things like the script name and
path info to reflect how much of the URI has been processed and
also automatically remap it as necessary to support operation
of nested middleware components. This componentised approach can
certainly make it easier to implement more complex systems where
there is a mix of physical and virtual resources. You might thus
want to consider using WSGI on top of mod_python to make use of that
top of model. Alternatively, I have been working on similar stuff
for mod_python for a while, even before knowing that WSGI was doing
a similar thing, but want I am doing is still in a slightly volatile
state. If you are interested though, we can take the discussion
off list.....


More information about the Mod_python mailing list