[mod_python] Problem with using apache.import_module for importing scripts

Gregory (Grisha) Trubetskoy grisha at modpython.org
Wed Sep 3 15:58:13 EST 2003


Thanks, that should work OK, and it's still secure because it doesn't
allow access to arbitrary imported modules.

But as a sidenote - you should consider naming your scripts differently
since you end up having to reload them every time the "other" script is
accessed. Also, you may sometimes find object from one script in the
namespace of the other (not sure if it's a Python bug or feature).

Grisha

On Wed, 3 Sep 2003, Ron Alford wrote:

> On Wed, 3 Sep 2003, Ron Alford wrote:
>
> > import_module has a tendency to throw 404s when you have multiple scripts
> > of the same name in different directories.  Is there a known way of
> > getting around this problem?
> >
> > My own mod_python handler is effected, and I suspect publisher is, too.
> >
>
> This is how I fixed it in apache.py:
> ...
> if not file or (path and not os.path.dirname(file) in path):
>     raise SERVER_RETURN, HTTP_NOT_FOUND
> if autoreload:
> ...
>
> goes to
> ...
> if not file or (path and not os.path.dirname(file) in path):
>     #raise SERVER_RETURN, HTTP_NOT_FOUND
>     mtime, oldmtime = 0, -1
> elif autoreload:
> ...
>
> --
> Ron Alford, KB0NUV
> http://volus.net/~ronwalf
>
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>


More information about the Mod_python mailing list