[mod_python] My template script isn't working

Graham Dumpleton grahamd at dscpl.com.au
Mon Aug 29 08:37:39 EDT 2005

On 29/08/2005, at 10:23 PM, Anton wrote:

> I have read your articles. Well written :)
> I think I know exactly what particular problem I am having
> As it is written here http://issues.apache.org/jira/browse/ 
> "This means that if one restores an old version of a file from backup,
> eg., by using "mv" command from another location, it will not reload
> it and it is necessary to touch the file or restart Apache."
> I upgraded to mod_python 3.2.0 but anyway bug still persists.
> 'if mtime != oldmtime' is in apache.py though
> Here is how my files are arranged:
> ftp://selecter.no-ip.org/py-homepage/

Have a play with this instead (untested):

   from mod_python import apache
   psp = apache.import_module("mod_python.psp")
   import os,sys

   __here__ = os.path.dirname(__file__)
   __include_dir = os.path.join(__here__,'include')

   def index(req):
       quote_of_the_day = apache.import_module 
       req.content_type = 'text/html'
       tmpl = psp.PSP(req, filename=os.path.join(__here__, 'templates/ 
       tmpl.run( vars={'QUOTE':quote_of_the_day.today_quote()} )

By using "import_module()" within the scope of the executing handler,  
a check
is made on each request as to whether the quote Python code file has  
and it will be reloaded if necessary when it does.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050829/f4f4eb36/attachment.html

More information about the Mod_python mailing list