On 18/05/07, Daniel J. Popowich <[EMAIL PROTECTED]> wrote:

Graham Dumpleton writes:
> Read:
>   http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html
> Especially the area which starts just before:
>   PythonOption mod_python.importer.path "['~']"
> Your particular issue is mentioned just after this example.

Doesn't work, either in .htaccess or in <Directory> directives.  This
is what I have in my apache config:

        <Directory "/home/dpopowich/public_html/py">
            SetHandler mod_python

            PythonHandler mod_python.servlet
            PythonOption mod_python.importer.path "['~']"
            PythonDebug on

When I go to http://localhost/~dpopowich/py/syspath, a simple
mpservlet that writes out the current value of sys.path, I do NOT see
/home/dpopowich/public_html/py in the path.

You will not see the path listed in sys.path. The mod_python module
importer path and the Python sys.path are deliberately kept separate
because of all the problems caused by each looking in the same

And when I try to import
a python module in that directory, I get import errors.

If you are still using the old module importer in mpservlets to import
your .mps file then that would probably still occur.

However, if I put this in my apache global context:

    PythonOption mod_python.legacy.importer *

this fixes my immediate problem.

Is this the way to completely turn this subsystem OFF?

Yes, but the old importer will disappear at some point in the future.

As a side note: I've been away from mod_python for a while and now am
getting back into things and thought one project would be to update
mpservlets to use the new importer I've heard so much about instead of
the one I wrote for mpservlets.  I must confess I'm a bit taken aback
that it takes over six pages to document this one function

Considering the list of problems with the old importer came to about
12 pages, I thought it wasn't too bad. :-)


and a quick
read has left me scratching my head and wondering if this is the way I
want to go.  I must confess I find it less than intuitive.

Just change this in your mpservlets package. The new importer can
handle arbitrary extensions so can load .mps files no problem. With
just this change your tutorial example works with no problems and it
uses 'import' to get stuff from handler directory.

kundalini:/usr/local/src/mpservlets-1.1.6 grahamd$ diff
servlet.py.dist servlet.py
<             code = {}
<             execfile(fname, code)
            #code = {}
            #execfile(fname, code)
            module = apache.import_module(fname)
<                 klass = code[basename]
                #klass = code[basename]
                klass = getattr(module, basename)


Reply via email to