Mercurial > piecrust2
changeset 111:208c652551a3
Quick fix for making the server correctly update referenced pages.
Disable the file-system cache for rendered segments when in server mode. We
can bring this optimization back when we're actually using the baking record
in the server too in order to know dependencies.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 16 Oct 2014 17:03:42 -0700 |
parents | 7f00176a3b4d |
children | d31cbbdb4ecc |
files | piecrust/environment.py piecrust/serving.py |
diffstat | 2 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/environment.py Thu Oct 16 08:19:02 2014 -0700 +++ b/piecrust/environment.py Thu Oct 16 17:03:42 2014 -0700 @@ -115,11 +115,14 @@ self.was_cache_cleaned = False self.page_repository = MemCache() self.rendered_segments_repository = MemCache() + self.fs_caches = { + 'renders': self.rendered_segments_repository} self.base_asset_url_format = '%uri%' def initialize(self, app): - cache = app.cache.getCache('renders') - self.rendered_segments_repository.fs_cache = cache + for name, repo in self.fs_caches.items(): + cache = app.cache.getCache(name) + repo.fs_cache = cache class StandardEnvironment(Environment):
--- a/piecrust/serving.py Thu Oct 16 08:19:02 2014 -0700 +++ b/piecrust/serving.py Thu Oct 16 17:03:42 2014 -0700 @@ -15,6 +15,7 @@ from piecrust.app import PieCrust from piecrust.data.filters import (PaginationFilter, HasFilterClause, IsFilterClause) +from piecrust.environment import StandardEnvironment from piecrust.page import Page from piecrust.processing.base import ProcessorPipeline from piecrust.rendering import PageRenderingContext, render_page @@ -24,6 +25,12 @@ logger = logging.getLogger(__name__) +class ServingEnvironment(StandardEnvironment): + def __init__(self): + super(ServingEnvironment, self).__init__() + del self.fs_caches['renders'] + + class Server(object): def __init__(self, root_dir, host='localhost', port='8080', debug=False, static_preview=True, @@ -77,7 +84,8 @@ raise MethodNotAllowed() # Create the app for this request. - app = PieCrust(root_dir=self.root_dir, debug=self.debug) + env = ServingEnvironment() + app = PieCrust(root_dir=self.root_dir, debug=self.debug, env=env) app.config.set('site/root', '/') app.config.set('site/pretty_urls', True) app.config.set('server/is_serving', True)