quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Eloff" <dan.el...@gmail.com>
Subject Graham: Suggested change to importer.py
Date Sat, 12 Aug 2006 17:43:41 GMT
I had some modules with circular imports and I only discovered that
this was a problem when I tried to discover why my modules were being
reimported constantly. I would suggest that this code be changed to
log an error that explicitly tells you that there's a circular import,
and what the consequences are.

# Check for a child which refers to one of its
# ancestors. Hopefully this will never occur. If
# it does we will force a reload every time to
 # highlight there is a problem.

if label in ancestors:
    # LOG HELPFUL ERROR HERE
    return True

Also, I still chafe every time I have to write:

sidewinder_dir = r'C:\Docume~1\Dan\MyDocu~1\PYROOT\sidewinder\\'
from mod_python import apache
session = apache.import_module(sidewinder_dir+'session.py')
config = apache.import_module(sidewinder_dir+'config.py')

Instead of:
import session
import config

My handler imports modules like so:

IMPORT_PATH = [config.server_options['sidewinder_dir'], config.web['root']]
apache.import_module(mpath, path=IMPORT_PATH)

Which works great, but when those modules import something I have to
use the ugly mess above. Maybe you and I could think of a better way?

I'd like if I could just add an option globally to my httpd.conf like:
PythonOption ChildrenAlwaysInheritImportPath On

Or maybe add another parameter to import_module like:
apache.import_module(mpath, path=IMPORT_PATH, inherit=True)

Or?

Thanks,
-Dan

Mime
View raw message