Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: template.py
- ===================================================================
- --- template.py (revision 348)
- +++ template.py (working copy)
- @@ -1314,9 +1314,8 @@
- directly
- @param cls: the class of the template object to instantiate
- """
- - if relative_to:
- - filename = os.path.join(os.path.dirname(relative_to), filename)
- - filename = os.path.normpath(filename)
- + filepath = filename
- + filepath = os.path.normpath(filepath)
- self._lock.acquire()
- try:
- @@ -1329,25 +1328,37 @@
- except KeyError:
- pass
- - # Bypass the search path if the filename is absolute
- search_path = self.search_path
- +
- if os.path.isabs(filename):
- + # Bypass the normal search path if the requested filename is absolute
- search_path = [os.path.dirname(filename)]
- + elif relative_to:
- + if os.path.isabs(relative_to):
- + # then make sure that the directory containing the
- + # template is on the search path
- + search_path.append(os.path.dirname(relative_to))
- + else:
- + filepath = os.path.join(os.path.dirname(relative_to), filepath)
- +
- + print filename, relative_to, filepath, repr(search_path)
- +
- if not search_path:
- + # Uh, oh, don't know where to look for the template
- raise TemplateError('Search path for templates not configured')
- for dirname in search_path:
- - filepath = os.path.join(dirname, filename)
- + path = os.path.join(dirname, filepath)
- try:
- - fileobj = open(filepath, 'U')
- + fileobj = open(path, 'U')
- try:
- - tmpl = cls(fileobj, basedir=dirname, filename=filename,
- + tmpl = cls(fileobj, basedir=dirname, filename=filepath,
- loader=self)
- finally:
- fileobj.close()
- self._cache[filename] = tmpl
- - self._mtime[filename] = os.path.getmtime(filepath)
- + self._mtime[filename] = os.path.getmtime(path)
- return tmpl
- except IOError:
- continue
Add Comment
Please, Sign In to add comment