[mod_python] Why this code fails?

Luis M. González luismg at gmx.net
Sun Nov 19 21:42:16 EST 2006

Hello all,

I have this script, which works fine when tested with the interpreter,
but fails when used with mod_python:

# index.py

import sys, os
sys.path.append(os.getcwd() + '/templates')
sys.path.append(os.getcwd() + '/models')
from models import *

result = Customers.select()

def index(req):
    req.content_type = 'text/html'
    for i in result:
        req.write(i.Company + '<br>')

I have a main directory and two subdirectories: templates and models.
Inside the models folder I have a module called "models.py", where I
imported an ORM and defined the db connection and models (included

Although it works perfectly as a standalone app, it doesn't work with
The error message I get is:

             NameError: name 'Clientes' is not defined

I guess it has to do with the way mod_python handles the import of
modules, or perhaps with the way I modify the sys.path... but I can't
figure out the solution.

Any hint would be highly appreciated...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20061119/1e69f628/attachment.html

More information about the Mod_python mailing list