diff options
Diffstat (limited to 'mako')
| -rw-r--r-- | mako/lookup.py | 18 | ||||
| -rw-r--r-- | mako/util.py | 5 |
2 files changed, 14 insertions, 9 deletions
diff --git a/mako/lookup.py b/mako/lookup.py index 7450700..d3763d6 100644 --- a/mako/lookup.py +++ b/mako/lookup.py @@ -287,16 +287,20 @@ class TemplateLookup(TemplateCollection): def _check(self, uri, template): if template.filename is None: return template - if not os.path.exists(template.filename): + + try: + template_stat = os.stat(template.filename) + if template.module._modified_time < \ + template_stat[stat.ST_MTIME]: + self._collection.pop(uri, None) + return self._load(template.filename, uri) + else: + return template + except OSError: self._collection.pop(uri, None) raise exceptions.TemplateLookupException( "Cant locate template for uri %r" % uri) - elif template.module._modified_time < \ - os.stat(template.filename)[stat.ST_MTIME]: - self._collection.pop(uri, None) - return self._load(template.filename, uri) - else: - return template + def put_string(self, uri, text): """Place a new :class:`.Template` object into this diff --git a/mako/util.py b/mako/util.py index 23a3277..3613a5b 100644 --- a/mako/util.py +++ b/mako/util.py @@ -21,6 +21,7 @@ else: from StringIO import StringIO import codecs, re, weakref, os, time, operator +import collections try: import threading @@ -114,7 +115,7 @@ class FastEncodingBuffer(object): but doesnt crash on unicode data like cStringIO.""" def __init__(self, encoding=None, errors='strict', unicode=False): - self.data = [] + self.data = collections.deque() self.encoding = encoding if unicode: self.delim = u'' @@ -125,7 +126,7 @@ class FastEncodingBuffer(object): self.write = self.data.append def truncate(self): - self.data =[] + self.data =collections.deque() def getvalue(self): if self.encoding: |
