Commit a8e04abb authored by Hanno Schlichting's avatar Hanno Schlichting

Add a convinient way to enable Zope's debug mode from the runwsgi command.

parent d4cf3d19
......@@ -45,6 +45,18 @@ To run Zope without detaching from the console, use:
In this mode, Zope emits its log messages to the console, and does not
detach from the terminal.
By default this command does not enable Zope's debug mode, so it can
be used for production.
In order to enable debug_mode, you can add the additional `-d` or
``--debug`` argument to the command:
.. code-block:: sh
$ bin/runwsgi -v etc/zope.ini -d
Starting server in PID 55111.
serving on http://127.0.0.1:8080
The runwsgi commands takes a PasteDeploy configuration file as its
argument. You can configure different WSGI capable servers,
the WSGI pipeline or logging configuration in this file.
......
......@@ -177,6 +177,9 @@ class ApplicationManager(Folder, CacheManager):
def thread_get_ident(self):
return get_ident()
def debug_mode(self):
return getConfiguration().debug_mode
def db_name(self):
return self._p_jar.db().getName()
......
......@@ -67,6 +67,18 @@ The Control Panel provides access to system information.
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Debug mode
</div>
</td>
<td align="left" valign="top">
<div class="form-text">
&dtml-debug_mode;
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
......
......@@ -58,6 +58,9 @@ def make_wsgi_app(global_config, zope_conf):
from ZPublisher.WSGIPublisher import publish_module
starter = get_wsgi_starter()
opts = ZopeWSGIOptions(configfile=zope_conf)()
if 'debug_mode' in global_config:
if global_config['debug_mode'] in ('true', 'on', '1'):
opts.configroot.debug_mode = True
handleWSGIConfig(opts.configroot, opts.confighandlers)
setConfiguration(opts.configroot)
starter.setConfiguration(opts.configroot)
......
......@@ -122,6 +122,12 @@ and then use %(http_port)s in your config files.
const=0,
dest='verbose',
help="Suppress verbose output")
parser.add_option(
'-d', '--debug',
action='store_const',
const=1,
dest='debug',
help="Enable debug mode.")
_scheme_re = re.compile(r'^[a-z][a-z]+:', re.I)
......@@ -170,6 +176,8 @@ and then use %(http_port)s in your config files.
server = self.loadserver(server_spec, name=server_name,
relative_to=base, global_conf=vars)
if 'debug_mode' not in vars and self.options.debug:
vars['debug_mode'] = 'true'
app = self.loadapp(app_spec, name=app_name, relative_to=base,
global_conf=vars)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment