comparison piecrust/serving/server.py @ 375:aade4ea57e7f

serve: Add ability to suppress the debug info window programmatically.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 07 May 2015 22:46:44 -0700
parents fa3ee8a8ee2d
children f33712c4cfab
comparison
equal deleted inserted replaced
374:fa3ee8a8ee2d 375:aade4ea57e7f
52 return self.server._run_request(environ, start_response) 52 return self.server._run_request(environ, start_response)
53 53
54 54
55 class Server(object): 55 class Server(object):
56 def __init__(self, root_dir, 56 def __init__(self, root_dir,
57 debug=False, sub_cache_dir=None, 57 debug=False, sub_cache_dir=None, enable_debug_info=True,
58 static_preview=True, run_sse_check=None): 58 static_preview=True, run_sse_check=None):
59 self.root_dir = root_dir 59 self.root_dir = root_dir
60 self.debug = debug 60 self.debug = debug
61 self.sub_cache_dir = sub_cache_dir 61 self.sub_cache_dir = sub_cache_dir
62 self.enable_debug_info = enable_debug_info
62 self.run_sse_check = run_sse_check 63 self.run_sse_check = run_sse_check
63 self.static_preview = static_preview 64 self.static_preview = static_preview
64 self._out_dir = None 65 self._out_dir = None
65 self._page_record = None 66 self._page_record = None
66 self._proc_loop = None 67 self._proc_loop = None
121 app = PieCrust(root_dir=self.root_dir, debug=self.debug) 122 app = PieCrust(root_dir=self.root_dir, debug=self.debug)
122 app._useSubCacheDir(self.sub_cache_dir) 123 app._useSubCacheDir(self.sub_cache_dir)
123 app.config.set('site/root', '/') 124 app.config.set('site/root', '/')
124 app.config.set('server/is_serving', True) 125 app.config.set('server/is_serving', True)
125 if (app.config.get('site/enable_debug_info') and 126 if (app.config.get('site/enable_debug_info') and
127 self.enable_debug_info and
126 '!debug' in request.args): 128 '!debug' in request.args):
127 app.config.set('site/show_debug_info', True) 129 app.config.set('site/show_debug_info', True)
128 130
129 # We'll serve page assets directly from where they are. 131 # We'll serve page assets directly from where they are.
130 app.env.base_asset_url_format = '/_asset/%path%' 132 app.env.base_asset_url_format = '/_asset/%path%'