Mercurial > piecrust2
comparison piecrust/serving.py @ 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 | de257cc40ce1 |
comparison
equal
deleted
inserted
replaced
110:7f00176a3b4d | 111:208c652551a3 |
---|---|
13 from werkzeug.wsgi import wrap_file | 13 from werkzeug.wsgi import wrap_file |
14 from jinja2 import FileSystemLoader, Environment | 14 from jinja2 import FileSystemLoader, Environment |
15 from piecrust.app import PieCrust | 15 from piecrust.app import PieCrust |
16 from piecrust.data.filters import (PaginationFilter, HasFilterClause, | 16 from piecrust.data.filters import (PaginationFilter, HasFilterClause, |
17 IsFilterClause) | 17 IsFilterClause) |
18 from piecrust.environment import StandardEnvironment | |
18 from piecrust.page import Page | 19 from piecrust.page import Page |
19 from piecrust.processing.base import ProcessorPipeline | 20 from piecrust.processing.base import ProcessorPipeline |
20 from piecrust.rendering import PageRenderingContext, render_page | 21 from piecrust.rendering import PageRenderingContext, render_page |
21 from piecrust.sources.base import PageFactory, MODE_PARSING | 22 from piecrust.sources.base import PageFactory, MODE_PARSING |
22 | 23 |
23 | 24 |
24 logger = logging.getLogger(__name__) | 25 logger = logging.getLogger(__name__) |
26 | |
27 | |
28 class ServingEnvironment(StandardEnvironment): | |
29 def __init__(self): | |
30 super(ServingEnvironment, self).__init__() | |
31 del self.fs_caches['renders'] | |
25 | 32 |
26 | 33 |
27 class Server(object): | 34 class Server(object): |
28 def __init__(self, root_dir, host='localhost', port='8080', | 35 def __init__(self, root_dir, host='localhost', port='8080', |
29 debug=False, static_preview=True, | 36 debug=False, static_preview=True, |
75 if self.static_preview and request.method != 'GET': | 82 if self.static_preview and request.method != 'GET': |
76 logger.error("Only GET requests are allowed, got %s" % request.method) | 83 logger.error("Only GET requests are allowed, got %s" % request.method) |
77 raise MethodNotAllowed() | 84 raise MethodNotAllowed() |
78 | 85 |
79 # Create the app for this request. | 86 # Create the app for this request. |
80 app = PieCrust(root_dir=self.root_dir, debug=self.debug) | 87 env = ServingEnvironment() |
88 app = PieCrust(root_dir=self.root_dir, debug=self.debug, env=env) | |
81 app.config.set('site/root', '/') | 89 app.config.set('site/root', '/') |
82 app.config.set('site/pretty_urls', True) | 90 app.config.set('site/pretty_urls', True) |
83 app.config.set('server/is_serving', True) | 91 app.config.set('server/is_serving', True) |
84 | 92 |
85 # We'll serve page assets directly from where they are. | 93 # We'll serve page assets directly from where they are. |