Commit 87bd58fa authored by Łukasz Nowak's avatar Łukasz Nowak

Use zope.conf product statement.

Thanks to this no inplace code changes are required to activate product
functionality.
parent 8a55cb19
......@@ -25,9 +25,14 @@ please check the event.log for ERROR message.
Configuration
-------------
You must edit the file custom.py for your needs. You have to change
ACTIVATED to True, and change SECRET. You may change the URL that's
intercepted by the hook to do the dump.
You must edit your zope.conf file and add product configuration:
<product-config deadlockdebugger>
dump_url /manage_debug_threads
secret mysecretkey
</product-config>
secret is optional.
Usage
-----
......@@ -42,7 +47,7 @@ A secret is needed because Zope doesn't do any access control on the URL
(it is intercepted too early), and the thread traceback dump may return
sensitive information about the requests being executed. If you know
your Zope will only be accessed by authorized persons anyway, you can
set SECRET to the empty string, and just call::
set secret to the empty string, and just call::
http://yourzopesite:8080/manage_debug_threads
......
......@@ -22,23 +22,29 @@
This adds a ZServer hook so that if a special URL is called, a full dump
with tracebacks of the running python threads will be made.
You MUST configure the file custom.py before use.
You MUST configure zope.conf before use.
"""
import custom
from zLOG import LOG, INFO, ERROR
from App.config import getConfiguration
try:
import threadframe
except ImportError:
LOG('DeadlockDebugger', ERROR, "Incorrectly installed threadframe module")
else:
if not custom.ACTIVATED:
LOG('DeadlockDebugger', INFO,
"Not activated, you must change ACTIVATED in custom.py")
elif custom.SECRET == 'secret':
LOG('DeadlockDebugger', ERROR,
"Not activated, you must change SECRET in custom.py")
config = getConfiguration()
deadlockdebugger = config.product_config.get('deadlockdebugger')
dump_url = ''
secret = ''
if deadlockdebugger is None:
LOG('DeadlockDebugger', ERROR, 'Missing configuration statement '
'<product-config deadlockdebugger>, not activated')
else:
import dumper
LOG('DeadlockDebugger', INFO, "Installed")
if not 'dump_url' in deadlockdebugger:
LOG('DeadlockDebugger', ERROR, 'Please configure dump_url and '
'optionally secret in <product-config deadlockdebugger>, not '
'activated')
else:
import dumper
LOG('DeadlockDebugger', INFO, "Installed")
# Customize this file for your specific configuration.
# You *must* change ACTIVATED and SECRET.
#
# The URL to use for the dump is DUMP_URL?SECRET
# If SECRET is empty, DUMP_URL is enough.
#
# *** NOTE ABOUT SECURITY ***
#
# No Zope access control is done on this URL, as it is interpreted
# before the Zope application server comes into play. That's why you
# should change the secret or filter this URL before it gets to Zope,
# for instance in Apache.
ACTIVATED = False
SECRET = 'secret' # you must change this
DUMP_URL = '/manage_debug_threads'
......@@ -28,10 +28,8 @@ import traceback
import time
from cStringIO import StringIO
from zLOG import LOG, DEBUG
import custom
from zLOG import LOG, DEBUG, ERROR
from App.config import getConfiguration
def dump_threads():
"""Dump running threads
......@@ -74,9 +72,15 @@ def dump_threads():
res.append("End of dump")
return '\n'.join(res)
dump_url = custom.DUMP_URL
if custom.SECRET:
dump_url += '?'+custom.SECRET
config = getConfiguration()
deadlockdebugger = config.product_config.get('deadlockdebugger')
dump_url = ''
secret = ''
dump_url = deadlockdebugger['dump_url']
secret = deadlockdebugger.get('secret', '')
if dump_url and secret:
dump_url += '?'+secret
def match(self, request):
uri = request.uri
......
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