Mercurial > piecrust2
view piecrust/templating/jinja/loader.py @ 935:7ecb946bfafd
admin: Lots of fixes for running the admin panel in a WSGI server.
- Use new source APIs in the dashboard to open WIP files.
- Fixed broken/outdated code in some views.
- Fixed cases when Flask is not running at the root URL by using the
`SCRIPT_NAME` variable somewhat more properly.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Oct 2017 09:15:16 -0700 |
parents | 1bb704434ee2 |
children |
line wrap: on
line source
import os.path from jinja2 import FileSystemLoader class PieCrustLoader(FileSystemLoader): def __init__(self, searchpath, encoding='utf-8'): super(PieCrustLoader, self).__init__(searchpath, encoding) self.segments_cache = {} def get_source(self, environment, template): if template.startswith('$seg='): filename, seg_content = self.segments_cache[template] mtime = os.path.getmtime(filename) def uptodate(): try: return os.path.getmtime(filename) == mtime except OSError: return False return seg_content, filename, uptodate return super(PieCrustLoader, self).get_source(environment, template)