[mod_python] Subinterpreters and index.py

Daniel J. Popowich dpopowich at mtrsd.k12.ma.us
Thu Jul 1 12:09:08 EDT 2004


> I'm encoutering an unexpected behaviours while using the publisher handlers
> and two index.py, one in /app/index.py and one in /app/subdir/index.py.
>  
> When I first call http://localhost/app/, /app/index.py is called. Then if I
> call http://localhost/app/subdir/, /app/subdir/index.py is called allright,
> but then if I try again http://localhost/app/, I always get
> /app/subdir/index.py !
>  
> Well, it turns out it's a FAQ, listed here :
>  
> http://www.modpython.org/FAQ/faqw.py?req=show&file=faq02.016.htp

This problem does NOT exist for Mod_python Servlets.  The servlet
handler does not use python's import system, instead it compiles each
servlet using execfile and the results stored in a cache, indexed by
servlets' full pathnames.  So, if I have two servlets:

  http://localhost/foo/index.mps 
  http://localhost/foo/bar/index.mps

and my document root is /var/www/html (so, directory /var/www/html/foo
is configured to use mod_python.servlet as a handler), then the cache
would have:

  '/var/www/html/foo/index.mps' : <instance of mod_python.servlet.Servlet>
  '/var/www/html/foo/bar/index.mps' : <instance of mod_python.servlet.Servlet>

Subsequent requests will look in the cache before compiling, so the
correct servlet will be found.

See:

    http://home.comcast.net/~d.popowich/mpservlets/

Cheers,

Daniel (humble author of Mod_python Servlets)



More information about the Mod_python mailing list