Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
Index: genshi/template.py =================================================================== --- genshi/template.py (revision 346) +++ genshi/template.py (working copy) @@ -1314,9 +1314,10 @@ directly @param cls: the class of the template object to instantiate """ + filepath = filename if relative_to: - filename = os.path.join(os.path.dirname(relative_to), filename) - filename = os.path.normpath(filename) + filepath = os.path.join(os.path.dirname(relative_to), filepath) + filepath = os.path.normpath(filepath) self._lock.acquire() try: @@ -1331,23 +1332,26 @@ # Bypass the search path if the filename is absolute search_path = self.search_path + filedir = os.path.dirname(filepath) if os.path.isabs(filename): - search_path = [os.path.dirname(filename)] + search_path = [filedir] + elif filedir not in search_path: + search_path.append(filedir) if not search_path: 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, 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
From the Design Piracy series on my blog: