Mercurial > piecrust2
comparison piecrust/serving.py @ 39:2f717f961996
Better error reporting and cache validation.
Fix the processor pipeline in the preview server.
Move the `pages` route to first position.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 21 Aug 2014 22:28:22 -0700 |
parents | 617191dec18e |
children | 73956224eb67 |
comparison
equal
deleted
inserted
replaced
38:091f99bfbe44 | 39:2f717f961996 |
---|---|
40 | 40 |
41 def run(self): | 41 def run(self): |
42 # Bake all the assets so we know what we have, and so we can serve | 42 # Bake all the assets so we know what we have, and so we can serve |
43 # them to the client. We need a temp app for this. | 43 # them to the client. We need a temp app for this. |
44 app = PieCrust(root_dir=self.root_dir, debug=self.debug) | 44 app = PieCrust(root_dir=self.root_dir, debug=self.debug) |
45 mounts = app.assets_dirs | |
45 self._out_dir = os.path.join(app.cache_dir, 'server') | 46 self._out_dir = os.path.join(app.cache_dir, 'server') |
46 self._skip_patterns = app.config.get('baker/skip_patterns') | 47 self._skip_patterns = app.config.get('baker/skip_patterns') |
47 self._force_patterns = app.config.get('baker/force_patterns') | 48 self._force_patterns = app.config.get('baker/force_patterns') |
48 pipeline = ProcessorPipeline( | 49 pipeline = ProcessorPipeline( |
49 app, self._out_dir, | 50 app, mounts, self._out_dir, |
50 skip_patterns=self._skip_patterns, | 51 skip_patterns=self._skip_patterns, |
51 force_patterns=self._force_patterns) | 52 force_patterns=self._force_patterns) |
52 self._record = pipeline.run() | 53 self._record = pipeline.run() |
53 | 54 |
54 # Run the WSGI app. | 55 # Run the WSGI app. |
110 return None | 111 return None |
111 | 112 |
112 # Yep, we know about this URL because we processed an asset that | 113 # Yep, we know about this URL because we processed an asset that |
113 # maps to it... make sure it's up to date by re-processing it | 114 # maps to it... make sure it's up to date by re-processing it |
114 # before serving. | 115 # before serving. |
115 asset_in_path = os.path.join(app.root_dir, entry.rel_input) | 116 mounts = app.assets_dirs |
117 asset_in_path = entry.path | |
116 asset_out_path = os.path.join(self._out_dir, rel_req_path) | 118 asset_out_path = os.path.join(self._out_dir, rel_req_path) |
117 pipeline = ProcessorPipeline( | 119 pipeline = ProcessorPipeline( |
118 app, self._out_dir, | 120 app, mounts, self._out_dir, |
119 skip_patterns=self._skip_patterns, | 121 skip_patterns=self._skip_patterns, |
120 force_patterns=self._force_patterns) | 122 force_patterns=self._force_patterns) |
121 pipeline.run(asset_in_path) | 123 pipeline.run(asset_in_path) |
122 | 124 |
123 logger.debug("Serving %s" % asset_out_path) | 125 logger.debug("Serving %s" % asset_out_path) |