Graham Dumpleton
grahamd at dscpl.com.au
Wed Sep 29 18:10:10 EDT 2004
On Sep 29 18:47, Juergen Fiedler <juergen at fiedlerfamily.net> wrote: > > Subject: [mod_python] Request For Input > > I am beginning to learn mod_python; I have just written the skeleton of > a web application, but have no idea where exactly the glaring holes are > could someone please take a look at the code and tell me whether I am on > the right track? > > ... > > The idea is that the main handler takes a URL like > 'http://www.test.com/main.py/test' and separates the last part > (everything after the 'main.py/'). It then loads a Handler class from a > module of that name in the site_code package. Then it instantiates an > object of that class and calls the 'handle' method. > I purposely did not touch anything but the default handler yet. > > Now the big question: Is this a valid way to go about writing a web > application in mod_python or am I completely on the wrong track? The > exec calls in the main handler are probably not optimal when it comes to > ~ execution speed, but I couldn't think of anything better to do to > import a module dynamically based on external variables. > > Any input would be greatly appreciated. Instead of exec'ing import, use mod_python.apache.import_module() method. You might also have a look at Vampire: http://www.dscpl.com.au/projects/vampire It also implements a high level handler which acts as a switch between subordinate content handlers stored in separate code files. There is a newer version of Vampire code ready to be released, but still updating documentation. -- Graham Dumpleton (grahamd at dscpl.com.au)
|