Skip to content

Instantly share code, notes, and snippets.

View timonweb's full-sized avatar

Timur timonweb

View GitHub Profile
@timonweb
timonweb / sqldump_middleware.py
Created May 23, 2012 07:45 — forked from kesor/sqldump_middleware.py
Django SQL dump middleware
from django.conf import settings
from django.db import connection
class SqldumpMiddleware(object):
def process_response(self, request, response):
if settings.DEBUG and 'sqldump' in request.GET:
response.content = str(connection.queries)
response['Content-Type'] = 'text/plain'
return response
@timonweb
timonweb / profile_middleware.py
Created May 23, 2012 07:45 — forked from kesor/profile_middleware.py
Django cProfile middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
import cProfile
import pstats
import marshal
from cStringIO import StringIO
class ProfileMiddleware(object):
def __init__(self):
if not settings.DEBUG: