[mod_python] How can I have sensible URLs?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Wed Sep 4 16:07:58 EST 2002


You could also separate your app into different modules, then write
libdb.py so that all its functions do is call functions from your other
modules, e.g.:

Assuming there is a libsearch.py which contains all the code necessary
for searching, in libdb.py you'd have:

import libsearch

def search():
	return libsearch.search()

The only caveat with this approach is described here:

http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.001.htp

Grisha

On Wed, 4 Sep 2002, Peter Bittner wrote:

> In my case I think there is some more to it. I'll try to sketch it out:
> Say, I have the following scripts that form a user interface to a library
> database (say, I'm using Python over CGI for this one here)
>
> - http://www.mydomain.com/libdb/index.py
> - http://www.mydomain.com/libdb/input.py
> - http://www.mydomain.com/libdb/search.py
> - http://www.mydomain.com/libdb/reports.py
> - http://www.mydomain.com/libdb/maintain.py
>
> I'm sure you can imagine that every script is doing a lot of stuff (printing
> out HTML forms, handling user actions and so on). - Let's see how I would
> implement this with mod_python:
>
> - I would write one large mod_python script called "libdb.py" which contains
> basically the whole code of all the above listed scripts. Each of the above
> scripts I would replace by methods (handlers) like "def index():", "def
> input():", "def search():", etc.
> Then I've ended up with a huge, almost unmaintainable script.  :-(
>
> Is there any way to avoid this?
> Would anyone tackle this problem differently?




More information about the Mod_python mailing list