Mercurial > piecrust2
comparison piecrust/serving/server.py @ 663:3ceeca7bb71c
themes: Add support for a `--theme` argument to `chef`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 01 Mar 2016 22:27:28 -0800 |
parents | 657384f08ca3 |
children | 81d9c3a3a0b5 |
comparison
equal
deleted
inserted
replaced
662:cbd5cdec0695 | 663:3ceeca7bb71c |
---|---|
69 return desc | 69 return desc |
70 | 70 |
71 | 71 |
72 class Server(object): | 72 class Server(object): |
73 def __init__(self, root_dir, | 73 def __init__(self, root_dir, |
74 debug=False, sub_cache_dir=None, enable_debug_info=True, | 74 debug=False, theme_site=False, |
75 sub_cache_dir=None, enable_debug_info=True, | |
75 root_url='/', static_preview=True): | 76 root_url='/', static_preview=True): |
76 self.root_dir = root_dir | 77 self.root_dir = root_dir |
77 self.debug = debug | 78 self.debug = debug |
79 self.theme_site = theme_site | |
78 self.sub_cache_dir = sub_cache_dir | 80 self.sub_cache_dir = sub_cache_dir |
79 self.enable_debug_info = enable_debug_info | 81 self.enable_debug_info = enable_debug_info |
80 self.root_url = root_url | 82 self.root_url = root_url |
81 self.static_preview = static_preview | 83 self.static_preview = static_preview |
82 self._page_record = ServeRecord() | 84 self._page_record = ServeRecord() |
108 if response is not None: | 110 if response is not None: |
109 return response | 111 return response |
110 | 112 |
111 # Create the app for this request. | 113 # Create the app for this request. |
112 app = get_app_for_server(self.root_dir, debug=self.debug, | 114 app = get_app_for_server(self.root_dir, debug=self.debug, |
115 theme_site=self.theme_site, | |
113 sub_cache_dir=self.sub_cache_dir, | 116 sub_cache_dir=self.sub_cache_dir, |
114 root_url=self.root_url) | 117 root_url=self.root_url) |
115 if (app.config.get('site/enable_debug_info') and | 118 if (app.config.get('site/enable_debug_info') and |
116 self.enable_debug_info and | 119 self.enable_debug_info and |
117 '!debug' in request.args): | 120 '!debug' in request.args): |
300 | 303 |
301 def _get_exception_descriptions(self, exception): | 304 def _get_exception_descriptions(self, exception): |
302 desc = [] | 305 desc = [] |
303 while exception is not None: | 306 while exception is not None: |
304 if isinstance(exception, MultipleNotFound): | 307 if isinstance(exception, MultipleNotFound): |
305 desc += [e.description for e in exception._nfes] | 308 desc += [str(e) for e in exception._nfes] |
306 elif isinstance(exception, HTTPException): | 309 elif isinstance(exception, HTTPException): |
307 desc.append(exception.description) | 310 desc.append(exception.get_description()) |
308 else: | 311 else: |
309 desc.append(str(exception)) | 312 desc.append(str(exception)) |
310 | 313 |
311 inner_ex = exception.__cause__ | 314 inner_ex = exception.__cause__ |
312 if inner_ex is None: | 315 if inner_ex is None: |