Mercurial > piecrust2
comparison piecrust/page.py @ 67:563ce5dd02af
I don't care what the YAML spec says, ordered maps are the only sane way.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 29 Aug 2014 16:42:15 -0700 |
parents | fce061f8c2ed |
children | e293f08d954e |
comparison
equal
deleted
inserted
replaced
66:e4a24512b814 | 67:563ce5dd02af |
---|---|
5 import os.path | 5 import os.path |
6 import hashlib | 6 import hashlib |
7 import logging | 7 import logging |
8 import datetime | 8 import datetime |
9 import dateutil.parser | 9 import dateutil.parser |
10 import collections | |
10 from werkzeug.utils import cached_property | 11 from werkzeug.utils import cached_property |
11 from piecrust.configuration import (Configuration, ConfigurationError, | 12 from piecrust.configuration import (Configuration, ConfigurationError, |
12 parse_config_header) | 13 parse_config_header) |
13 from piecrust.environment import PHASE_PAGE_PARSING | 14 from piecrust.environment import PHASE_PAGE_PARSING |
14 | 15 |
182 cache = app.cache.getCache('pages') | 183 cache = app.cache.getCache('pages') |
183 cache_path = "%s.json" % hashlib.md5(path.encode('utf8')).hexdigest() | 184 cache_path = "%s.json" % hashlib.md5(path.encode('utf8')).hexdigest() |
184 page_time = path_mtime or os.path.getmtime(path) | 185 page_time = path_mtime or os.path.getmtime(path) |
185 if cache.isValid(cache_path, page_time): | 186 if cache.isValid(cache_path, page_time): |
186 exec_info.was_cache_valid = True | 187 exec_info.was_cache_valid = True |
187 cache_data = json.loads(cache.read(cache_path)) | 188 cache_data = json.loads(cache.read(cache_path), |
189 object_pairs_hook=collections.OrderedDict) | |
188 config = PageConfiguration(values=cache_data['config'], | 190 config = PageConfiguration(values=cache_data['config'], |
189 validate=False) | 191 validate=False) |
190 content = json_load_segments(cache_data['content']) | 192 content = json_load_segments(cache_data['content']) |
191 return config, content | 193 return config, content |
192 | 194 |