[mod_python] Newbie: mod_python.publisher application structure

Graham Dumpleton grahamd at dscpl.com.au
Wed Jul 13 19:08:49 EDT 2005


On 14/07/2005, at 6:25 AM, Jorey Bump wrote:
>> As a web designer, navigation is very important to me so I plan 
>> websites
>> starting from the URL, my problem is that I can't think a class 
>> structure
>> that does the job:
>> myblogdomain.net/ myblogdomain.net/index     Resolved as the index 
>> page
>> myblogdomain.net/archives/2005/jun/    Resolved as 
>> blog.archives('2005','Jun')
>> myblogdomain.net/archives/2005           Resolved as 
>> blog.archives('2005')
>
> You'll probably want to do this instead:
>
> myblogdomain.net/archives?y=2005&m=jun

FWIW, if you had Vampire you could say:

   def _archives(year,month=None):
     ...

   archives = vampire.PathArgs(_archives)

Ie., it will resolve as:

   myblogdomain.net/archives/2005/jun/    Calls _archives('2005','jun')
   myblogdomain.net/archives/2005           Calls _archives('2005')

Note that this doesn't require you to be using Vampire's dispatch 
mechanism
or its version of publisher, this should work in stock standard version 
of
mod_python.publisher.

Unlike the vampire.PathInfo() class which can be ported to work with
mod_python.publisher such that there is no dependency on Vampire, that
can't be easily done with vampire.PathArgs() as it depends on some
introspection routines for which there is no equivalent in mod_python.
You would either have to rip the introspection routine out of Vampire
or write a replacement for it. It just uses the "inspect" module from
Python, so not too hard. :-)

Graham



More information about the Mod_python mailing list