Gregory (Grisha) Trubetskoy
grisha at modpython.org
Thu Jan 15 23:29:44 EST 2004
from mod_python import apache import os def handler(req): modname, ext = os.path.split(req.filename) if ext == '.pyx': pyx_mod = apache.import_module(modname) This code has not been tested :-) BTW - You should check out the publisher handler, it probably already does what you're trying to do. Grisha On Thu, 15 Jan 2004, Colin Fox wrote: > Hi, All. > > I've been playing with mod_python for a little while, and I love it! I > do have one puzzle, though. > > What would be the best way of executing an on-disk module? It would be > nice to be able to do something like: > > def handler(req): > modname = req.filename > if modname.endswith('.pyx'): > import modname > modname['main'](req) > > (I know this is very pseudo. It's just to convey what I mean.) > > But as far as I know, you can't use 'import' on a variable. > > I'd prefer to do this over invoking the python interpreter, of course, > to keep everything within the mod_python execution environment. > > Any suggestions? > > Thanks, > cf > > -- > Colin Fox <cfox at cfconsulting.ca> > CF Consulting Inc. >
|