[mod_python] PSP imports

Michael S. Fischer michael at dynamine.net
Mon Nov 24 22:43:43 EST 2003


Dan W. wrote:

> That's a good point Michael.  That was probably a bad habit to pick up.  
> However, I think a overloaded import could still be useful.  Overloading 
> the builtin import would allow a PSP file to control autoreloading for 
> its entire dependency tree (modules which call other modules, etc.).  
> This would allow one to easily turn autoreloading on during development 
> and to easily turn it off for production deployment.

Consider that you might want not to use PSP.  I've actually found that 
it gets in the way of the separation of code and content, which is 
important when the designer and the coder are two different people.

I design my mod_python apps like so:

template = """
<html>
...
<!-- have the designers place %(variable)s where necessary
      in the template for doing performing substitution
      during the processing phase -->
</html>
"""

def handler(req):
   # Reload modules here if necessary
   # Code goes here
   # If you want to override the template, you can fetch it from the file
   # system
   req.write(template % vars())

Of course, if you're already married to the PSP solution, then there you 
have it...

--Michael



More information about the Mod_python mailing list