update for latest djdt
This commit is contained in:
parent
c152d647e1
commit
ad9ccb6db1
|
@ -1,11 +1,5 @@
|
|||
from django.db.backends import util
|
||||
|
||||
try:
|
||||
has_toolbar = True
|
||||
from debug_toolbar.toolbar import loader
|
||||
except ImportError:
|
||||
has_toolbar = False
|
||||
|
||||
from django_statsd.patches.utils import wrap
|
||||
|
||||
|
||||
|
@ -41,27 +35,8 @@ def wrap_class(base):
|
|||
|
||||
return Wrapper
|
||||
|
||||
if has_toolbar:
|
||||
# This is where the fun begins. django-debug-toolbar monkey patches
|
||||
# util.CursorDebugWrapper so you can't monkey patch that if you want to
|
||||
# see the SQL queries that it spits out.
|
||||
old = loader.DebugToolbar.load_panels
|
||||
|
||||
# Even better, it only does this in the middleware, which is after the patch
|
||||
# so we monkey patch the loading of the patches. So once the toolbar has done
|
||||
# it's stuff we write out patch on top of it.
|
||||
def callback(self, *args, **kw):
|
||||
res = old(self, *args, **kw)
|
||||
from debug_toolbar.panels import sql
|
||||
# This will rewrap so this will work when DEBUG = True and the SQL Panel
|
||||
# is used in the toolbar.
|
||||
util.CursorDebugWrapper = wrap_class(sql.DatabaseStatTracker)
|
||||
return res
|
||||
|
||||
|
||||
def patch():
|
||||
if has_toolbar:
|
||||
loader.DebugToolbar.load_panels = callback
|
||||
# So that it will work when DEBUG = True.
|
||||
util.CursorDebugWrapper = wrap_class(util.CursorDebugWrapper)
|
||||
# So that it will work when DEBUG = False.
|
||||
|
|
|
@ -16,6 +16,10 @@ Credits:
|
|||
Changes
|
||||
-------
|
||||
|
||||
0.3.2:
|
||||
|
||||
- update to work with latest Django Debug Toolbar
|
||||
|
||||
0.3:
|
||||
|
||||
- added in logging handler for logging error counts to stats
|
||||
|
|
2
setup.py
2
setup.py
|
@ -5,7 +5,7 @@ from setuptools import setup
|
|||
setup(
|
||||
# Because django-statsd was taken, I called this django-statsd-mozilla.
|
||||
name='django-statsd-mozilla',
|
||||
version='0.3.1',
|
||||
version='0.3.2',
|
||||
description='Django interface with statsd',
|
||||
long_description=open('README.rst').read(),
|
||||
author='Andy McKay',
|
||||
|
|
Loading…
Reference in New Issue