[mod_python] Aliasing extensions in mod_python

Jorey Bump list at joreybump.com
Sun Aug 26 17:21:25 EDT 2007

Roger Holness wrote:

> The problem I am having is that my script returns valid wml but my
> phone that I am testing on (and I assume others as well) doesn't check
> the mime type, rather just the extension
> ie. www.mywebsite/wml.py/test  is returning valid wml, but the phone
> doesn't realise that as it is expecting /test.wml
> Now functions names can't contain periods, so I can't do:
> def test.wml(req)

You can create a class with a wml method. Then you create an instance of 
the class, and get at the method using dotted notation.

class Class:
     def __call__(self):
         return "I am the default method."
     def wml(self):
         page = <create wml page here>
         return page

test = Class()

Now you should be able to reach it via:


More information about the Mod_python mailing list