From 78f498c96ed3b236f04ebd018fdd562826c09d16 Mon Sep 17 00:00:00 2001 From: fergalmoran Date: Sat, 15 Jun 2013 22:10:44 +0100 Subject: [PATCH] 500 debugging... --- dss/settings.py | 4 ++-- dss/urls.py | 1 + spa/urls.py | 2 ++ spa/views.py | 13 +++++++++++++ templates/500.html | 2 +- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dss/settings.py b/dss/settings.py index 678b5fe..f163f3a 100644 --- a/dss/settings.py +++ b/dss/settings.py @@ -23,7 +23,7 @@ ADMINS = ( MANAGERS = ADMINS AUTH_PROFILE_MODULE = 'spa.UserProfile' -ALLOWED_HOSTS = localsettings.ALLOWED_HOSTS if hasattr(localsettings, 'ALLOWED_HOSTS') else [] +ALLOWED_HOSTS = ['*'] #localsettings.ALLOWED_HOSTS if hasattr(localsettings, 'ALLOWED_HOSTS') else [] DATABASES = { 'mysql': { 'ENGINE': 'django.db.backends.mysql', @@ -52,7 +52,7 @@ USE_TZ = True SITE_ROOT = here('') MEDIA_ROOT = localsettings.MEDIA_ROOT -STATIC_ROOT = here('static') #localsettings.STATIC_ROOT if hasattr(localsettings, 'STATIC_ROOT') else '' +STATIC_ROOT = '/var/www/deepsouthsounds.com/static' # here('static') #localsettings.STATIC_ROOT if hasattr(localsettings, 'STATIC_ROOT') else '' CACHE_ROOT = localsettings.CACHE_ROOT if DEBUG: diff --git a/dss/urls.py b/dss/urls.py index 5ea88d2..fc57a7c 100644 --- a/dss/urls.py +++ b/dss/urls.py @@ -25,6 +25,7 @@ urlpatterns = patterns('', (r'^tinymce/', include('tinymce.urls')), url(r'^', include('spa.urls')), ) +handler500 = 'spa.views.debug_500' if settings.DEBUG: from django.views.static import serve diff --git a/spa/urls.py b/spa/urls.py index 83605ca..922e3db 100644 --- a/spa/urls.py +++ b/spa/urls.py @@ -39,3 +39,5 @@ urlpatterns = patterns( url(r'^comments/', include('django.contrib.comments.urls')), (r'^.*/$', 'spa.views.default') ) + + diff --git a/spa/views.py b/spa/views.py index 6c3dde7..51d4643 100644 --- a/spa/views.py +++ b/spa/views.py @@ -33,3 +33,16 @@ def default(request): def upload(request): return render_to_response("inc/upload.html", context_instance=RequestContext(request)) + +def debug_500(request, template_name='debug_500.html'): + """ + 500 error handler. + + Templates: `500.html` + Context: sys.exc_info() results + """ + t = loader.get_template(template_name) # You need to create a 500.html template. + ltype,lvalue,ltraceback = sys.exc_info() + sys.exc_clear() #for fun, and to point out I only -think- this hasn't happened at + #this point in the process already + return http.HttpResponseServerError(t.render(Context({'type':ltype,'value':lvalue,'traceback':ltraceback}))) diff --git a/templates/500.html b/templates/500.html index 5165954..90f3899 100644 --- a/templates/500.html +++ b/templates/500.html @@ -16,4 +16,4 @@ - \ No newline at end of file +