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. ...@@ -25,9 +25,14 @@ please check the event.log for ERROR message.
Configuration Configuration
------------- -------------
You must edit the file custom.py for your needs. You have to change You must edit your zope.conf file and add product configuration:
ACTIVATED to True, and change SECRET. You may change the URL that's
intercepted by the hook to do the dump. <product-config deadlockdebugger>
dump_url /manage_debug_threads
secret mysecretkey
</product-config>
secret is optional.
Usage Usage
----- -----
...@@ -42,7 +47,7 @@ A secret is needed because Zope doesn't do any access control on the URL ...@@ -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 (it is intercepted too early), and the thread traceback dump may return
sensitive information about the requests being executed. If you know sensitive information about the requests being executed. If you know
your Zope will only be accessed by authorized persons anyway, you can 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 http://yourzopesite:8080/manage_debug_threads
......
...@@ -22,23 +22,29 @@ ...@@ -22,23 +22,29 @@
This adds a ZServer hook so that if a special URL is called, a full dump 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. 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 zLOG import LOG, INFO, ERROR
from App.config import getConfiguration
try: try:
import threadframe import threadframe
except ImportError: except ImportError:
LOG('DeadlockDebugger', ERROR, "Incorrectly installed threadframe module") LOG('DeadlockDebugger', ERROR, "Incorrectly installed threadframe module")
else: else:
if not custom.ACTIVATED: config = getConfiguration()
LOG('DeadlockDebugger', INFO, deadlockdebugger = config.product_config.get('deadlockdebugger')
"Not activated, you must change ACTIVATED in custom.py") dump_url = ''
elif custom.SECRET == 'secret': secret = ''
LOG('DeadlockDebugger', ERROR, if deadlockdebugger is None:
"Not activated, you must change SECRET in custom.py") LOG('DeadlockDebugger', ERROR, 'Missing configuration statement '
'<product-config deadlockdebugger>, not activated')
else:
if not 'dump_url' in deadlockdebugger:
LOG('DeadlockDebugger', ERROR, 'Please configure dump_url and '
'optionally secret in <product-config deadlockdebugger>, not '
'activated')
else: else:
import dumper import dumper
LOG('DeadlockDebugger', INFO, "Installed") 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 ...@@ -28,10 +28,8 @@ import traceback
import time import time
from cStringIO import StringIO from cStringIO import StringIO
from zLOG import LOG, DEBUG from zLOG import LOG, DEBUG, ERROR
from App.config import getConfiguration
import custom
def dump_threads(): def dump_threads():
"""Dump running threads """Dump running threads
...@@ -74,9 +72,15 @@ def dump_threads(): ...@@ -74,9 +72,15 @@ def dump_threads():
res.append("End of dump") res.append("End of dump")
return '\n'.join(res) return '\n'.join(res)
dump_url = custom.DUMP_URL config = getConfiguration()
if custom.SECRET: deadlockdebugger = config.product_config.get('deadlockdebugger')
dump_url += '?'+custom.SECRET dump_url = ''
secret = ''
dump_url = deadlockdebugger['dump_url']
secret = deadlockdebugger.get('secret', '')
if dump_url and secret:
dump_url += '?'+secret
def match(self, request): def match(self, request):
uri = request.uri 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