changeset 4621:7000bf88e348

MOIN_DEBUGGER=off/web/external
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 01 Mar 2009 18:15:00 +0100
parents 158a65df340e
children c24b810500b3
files MoinMoin/script/server/standalone.py MoinMoin/web/serving.py wiki/server/wikiserverconfig.py wikiserverconfig.py
diffstat 4 files changed, 32 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/server/standalone.py	Sun Mar 01 18:01:14 2009 +0100
+++ b/MoinMoin/script/server/standalone.py	Sun Mar 01 18:15:00 2009 +0100
@@ -50,8 +50,8 @@
             help="Set file to store pid of moin daemon in. Default: moin.pid"
         )
         self.parser.add_option(
-            "--debug", dest="debug", action="store_true",
-            help="Enable debug mode of server (show tracebacks)"
+            "--debug", dest="debug",
+            help="Debug mode of server. off: no debugging (default), web: for browser based debugging, external: for using an external debugger."
         )
 
     def mainloop(self):
@@ -105,7 +105,7 @@
             if self.options.interface is not None: # needs to work for "" value also
                 Config.interface = self.options.interface
             if self.options.debug:
-                Config.debug = True
+                Config.debug = self.options.debug
 
             if self.options.start:
                 daemon = Daemon('moin', pidfile, run_server, Config)
@@ -126,5 +126,5 @@
     group = None
     port = 8080
     interface = 'localhost'
-    debug = False
+    debug = 'off'
 
--- a/MoinMoin/web/serving.py	Sun Mar 01 18:01:14 2009 +0100
+++ b/MoinMoin/web/serving.py	Sun Mar 01 18:15:00 2009 +0100
@@ -129,7 +129,7 @@
     logging.info("Running as uid/gid %d/%d" % (uid, gid))
 
 def run_server(host='localhost', port=8080, docs=True,
-               threaded=True, debug=False, user=None, group=None):
+               threaded=True, debug='off', user=None, group=None):
     """ Run a standalone server on specified host/port. """
     application = make_application(shared=docs)
 
@@ -140,7 +140,13 @@
     if user:
         switch_user(user, group)
 
+    if debug == 'external':
+        # no threading is better for debugging, the main (and only)
+        # thread then will just terminate when an exception happens
+        threaded = False
+
     run_simple(host, port, application, threaded=threaded,
-               use_debugger=debug,
+               use_debugger=(debug == 'web'),
+               passthrough_errors=(debug == 'external'),
                request_handler=RequestHandler)
 
--- a/wiki/server/wikiserverconfig.py	Sun Mar 01 18:01:14 2009 +0100
+++ b/wiki/server/wikiserverconfig.py	Sun Mar 01 18:15:00 2009 +0100
@@ -29,16 +29,17 @@
     #threadLimit = 10
     #requestQueueSize = 50
 
-    # Use werkzeug's debugging middleware?
-    # debug can be either set to True or False to directly enable/disable
-    # the debugger.
-    # CAUTION: Do not use True for production environments as it might disclose
-    # sensitive informations and even enable doing evil things from the
-    # debugger's web interface!
+    # How to debug? Your options:
+    # debug = 'off' # for production wikis, exceptions are logged
+    # debug = 'web' # show traceback in the browser, offer debug console,
+    #               # this makes use of a built-in debugger (werkzeug.debug)
+    # debug = 'external' # don't catch Exceptions, so some external debugger gets them
+    # CAUTION: Do not use anything but 'off' for production environments as it
+    #          might disclose sensitive informations and even enable doing evil
+    #          things from some debugger's web interface!
     # For convenience, the default behaviour (see below) is to read the
-    # environment variable MOIN_DEBUGGER. Setting it to True will enable the
-    # debugger, anything else (or not setting it) will disable the debugger.
-    debug = os.environ.get('MOIN_DEBUGGER', 'False') == 'True'
+    # environment variable MOIN_DEBUGGER. If not set, it means the same as 'off'.
+    debug = os.environ.get('MOIN_DEBUGGER', 'off')
 
 # DEVELOPERS! Do not add your configuration items there,
 # you could accidentally commit them! Instead, create a
--- a/wikiserverconfig.py	Sun Mar 01 18:01:14 2009 +0100
+++ b/wikiserverconfig.py	Sun Mar 01 18:15:00 2009 +0100
@@ -29,16 +29,17 @@
     #threadLimit = 10
     #requestQueueSize = 50
 
-    # Use werkzeug's debugging middleware?
-    # debug can be either set to True or False to directly enable/disable
-    # the debugger.
-    # CAUTION: Do not use True for production environments as it might disclose
-    # sensitive informations and even enable doing evil things from the
-    # debugger's web interface!
+    # How to debug? Your options:
+    # debug = 'off' # for production wikis, exceptions are logged
+    # debug = 'web' # show traceback in the browser, offer debug console,
+    #               # this makes use of a built-in debugger (werkzeug.debug)
+    # debug = 'external' # don't catch Exceptions, so some external debugger gets them
+    # CAUTION: Do not use anything but 'off' for production environments as it
+    #          might disclose sensitive informations and even enable doing evil
+    #          things from some debugger's web interface!
     # For convenience, the default behaviour (see below) is to read the
-    # environment variable MOIN_DEBUGGER. Setting it to True will enable the
-    # debugger, anything else (or not setting it) will disable the debugger.
-    debug = os.environ.get('MOIN_DEBUGGER', 'False') == 'True'
+    # environment variable MOIN_DEBUGGER. If not set, it means the same as 'off'.
+    debug = os.environ.get('MOIN_DEBUGGER', 'off')
 
 # DEVELOPERS! Do not add your configuration items there,
 # you could accidentally commit them! Instead, create a