diff --git a/app/api/resource.py b/app/api/resource.py new file mode 100644 index 0000000..27b2822 --- /dev/null +++ b/app/api/resource.py @@ -0,0 +1,19 @@ +import sys +import logging + +from sentry.client.handlers import SentryHandler +from piston.resource import Resource + +class SentryResource(Resource): + + def error_handler(self, e, request, meth, em_format): + + print e + + logger = logging.getLogger('piston') + logger.addHandler(SentryHandler()) + + logger.error('Piston exception: %s(%s)' % (e.__class__.__name__, e), exc_info=sys.exc_info(), + extra={'data': {'handler': meth.im_class, 'request': request, 'get': dict(request.GET), 'post': dict(request.POST) }}) + + return Resource.error_handler(self, e, request, meth, em_format) diff --git a/app/api/urls.py b/app/api/urls.py index 026b613..2db1166 100755 --- a/app/api/urls.py +++ b/app/api/urls.py @@ -1,7 +1,7 @@ from django.conf.urls.defaults import * -from piston.resource import Resource from piston.authentication import NoAuthentication +from api.resource import SentryResource as Resource from api.auth import APIKeyAuthentication from api.handlers import * diff --git a/requirements.txt b/requirements.txt index b450c54..7a97451 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ MySQL-python Django==1.3 -django-piston==0.2.2 +-e hg+https://bitbucket.org/jespern/django-piston@c4b2d21db51a#egg=django_piston -e hg+https://bitbucket.org/ubernostrum/django-registration@d36a38202ee3#egg=django-registration yolk==0.4.1 -e hg+http://bitbucket.org/schinckel/django-jsonfield#egg=django-jsonfield