Mercurial > piecrust2
view piecrust/data/piecrustdata.py @ 666:81d9c3a3a0b5
internal: Get rid of the whole "sub cache" business.
* Compute cache keys up front, so the cache directory is only chosen once.
* Buffer up config variants to apply before loading the config. Makes it
possible to cache variant-resulting configs, too.
* Make a factory class to reuse the logic that creates the `PieCrust` object
correctly for multi-process workers and such.
* Add a test.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 03 Mar 2016 08:22:41 -0800 |
parents | 93b656f0af54 |
children | f71d576835ee |
line wrap: on
line source
import logging from piecrust import APP_VERSION from piecrust.data.debug import build_debug_info logger = logging.getLogger(__name__) class PieCrustData(object): debug_render = ['version', 'url', 'branding', 'debug_info'] debug_render_invoke = ['version', 'url', 'branding', 'debug_info'] debug_render_redirect = {'debug_info': '_debugRenderDebugInfo'} def __init__(self): self.version = APP_VERSION self.url = 'http://bolt80.com/piecrust/' self.branding = 'Baked with <em><a href="%s">PieCrust</a> %s</em>.' % ( 'http://bolt80.com/piecrust/', APP_VERSION) self._page = None @property def debug_info(self): if self._page is not None: try: return build_debug_info(self._page) except Exception as ex: logger.exception(ex) return ('An error occured while generating debug info. ' 'Please check the logs.') return '' def enableDebugInfo(self, page): self._page = page def _debugRenderDebugInfo(self): return "The very thing you're looking at!"