I found web.template cache the compiled template content in it's self._cache, 
but it can't check the orignal template file even if the template file has been 
changed. I add a modify_time flag in its cache, so now when template file 
changed, the compiled cache of this template will be automaticly renewed.

below is the modified code:
'''

    def _load_template(self, name):
        kind, path = self._lookup(name)
        mtime = os.stat(path)[8]
        if kind == 'dir': return Render(path, cache=self._cache is not None, 
base=self._base,
**self._keywords), mtime
        elif kind == 'file': return Template(open(path).read(), filename=path, 
**self._keyword
s), mtime
        else: raise AttributeError, "No template named " + name
    def _findfile(self, path_prefix):
        p = [f for f in glob.glob(path_prefix + '.*') if not f.endswith('~')] # 
skip backup fi
les
        return p and p[0]
    
    def _template(self, name):
        path = os.path.join(self._loc, name)
        kind, path = self._lookup(path)
        mtime = os.stat(path)[8]
        if name not in self._cache or mtime > self._cache[name][1]:
            self._cache[name] = self._load_template(name)
        return self._cache[name][0]

'''

2009-11-04 



shwdai 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to