MrLoick / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

allow administrator to turn DEBUG=True for a particular request #180

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
in the case that a particular url is throwing an error on the production
server and it is hard to debug with just a stack trace, it can be very
handy to get to the django debug view. The following changes to
ragendja.views.py allows a user to modify the request with a ?debugKey=xxx
parameter and see the standard debug view. The debugKey comes from the
settings so can be set by the administrator to a hard to guess string.

from django.http import HttpResponseServerError
from ragendja.template import render_to_string
from django.conf import settings
import logging, sys
def server_error(request, *args, **kwargs):
    if 'debugKey' in request.REQUEST and
request.REQUEST['debugKey']==settings.DEBUGKEY:
        from django.views import debug
        excInfo=sys.exc_info()
        return debug.technical_500_response(request, *excInfo)

    return HttpResponseServerError(render_to_string(request, '500.html'))

def maintenance(request, *args, **kwargs):
    return HttpResponseServerError(render_to_string(request,
        'maintenance.html'))

Original issue reported on code.google.com by jricket...@gmail.com on 8 Jul 2009 at 6:05

GoogleCodeExporter commented 8 years ago
Nice addition! It's in the repo, now. Thanks!

Original comment by wkornew...@gmail.com on 8 Jul 2009 at 11:51