Domanda

I am trying to find some way to set a breakpoint while running a Django server in dotcloud.

I found the following hopeful sounding link http://docs.dotcloud.com/tutorials/python/django/#advanced-debugging-with-werkzeug.

When I searched the web page however I could not find any reference to the debugger.

Is this function still available in dotcloud? If not is there another good option?

È stato utile?

Soluzione

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:

Altri suggerimenti

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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top