[mod_python] Testing for mod_python

Eric Brunson brunson at brunson.com
Fri Dec 1 13:42:18 EST 2006


I've converted my code over to use the 3.3 PythonOption mod_python.path, 
but our regression tests run outside of mod_python, so I need to 
conditionally mess with the sys.path.

I've come up with this:

try:
    # throws an exception when trying to load '_apache' outside mod_python
    from mod_python import apache
except ImportError:
    import sys
    sys.path.append( './lib' )

and it works fine, but is there a better way to do this check?

Thanks,
e.



More information about the Mod_python mailing list