[Answered ]-How to use werkzeug debugger in dotcloud?

1👍

Some things to think about before enabling the werkzeug debugger:

  • When you enable the werkzeug debugger, anyone triggering an exception
    will be able to access your code and your data (including database
    passwords and other sensitive credentials). Be careful and don’t
    leave it enabled longer than necessary, or add an extra protection
    layer to bar unauthorized users!
  • Once you’re done with the debugging, restore your old wsgi.py file
    and push your code again (you can leave werkzeug in your
    requirements.txt if you like; that does not matter).

Here’s what you can do to set it up:

1) add the following to your wsgi.py

# The following lines enable the werkzeug debugger
import django.views.debug

def null_technical_500_response(request, exc_type, exc_value, tb):
    raise exc_type, exc_value, tb
django.views.debug.technical_500_response = null_technical_500_response
from werkzeug.debug import DebuggedApplication
application = DebuggedApplication(application, evalex=True)

2) add the following to your requirements.txt

werkzeug

If you’d like to try out a quick sample of the debugger, I’ve setup example of the interactive debugger. This test app will only be available for a few days. http://django-johndotcloud.dotcloud.com/raise/

References:

1👍

The code in the answer above no longer works on Python 3.

Here’s how to do the same thing in Python 3.3:

import django.views.debug

def null_technical_500_response(request, exc_type, exc_value, tb):
    raise exc_type(exc_value).with_traceback(tb)
django.views.debug.technical_500_response = null_technical_500_response

from werkzeug.debug import DebuggedApplication
application = DebuggedApplication(application, evalex=True)

Leave a comment