Skip to content

Commit

Permalink
save pickled request to a file for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
anentropic committed Dec 26, 2012
1 parent 286ca85 commit 9120063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions ebaysync/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import copy
import logging
import os
import pickle
import warnings
from functools import wraps

from django.conf import settings
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseBadRequest
Expand All @@ -22,7 +25,7 @@
log = logging.getLogger(__name__)


def get_notification_url(usernasme=None):
def get_notification_url(username=None):
current_site = Site.objects.get_current()
if current_site.domain == 'example.com':
warnings.warn("You have not configured your Django sites framework, current site points to example.com")
Expand All @@ -32,6 +35,12 @@ def get_notification_url(usernasme=None):
@require_POST
@csrf_exempt
def notification(request, username=None):
if settings.DEBUG:
with open(os.path.join(settings.PROJECT_ROOT, 'last_request.pkl'), 'wb') as output:
meta = dict([(k,v) for k,v in request.META.items() if isinstance(v, basestring)])
obj = {'META': meta, 'body': request.body}
pickle.dump(obj, output)

try:
action = request.META['HTTP_SOAPACTION']
except KeyError:
Expand All @@ -55,8 +64,6 @@ def notification(request, username=None):
log.error(msg)
return HttpResponseBadRequest(msg)

user = UserToken.objects.get(ebay_username=for_user)

nh_kwargs = {}
if username is not None:
user = get_object_or_404(UserToken, ebay_username=username)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='django-ebaysync',
version='0.1.23',
version='0.1.32',
packages=[
'ebaysync',
'ebaysync.management',
Expand All @@ -14,6 +14,6 @@
author_email="ego@anentropic.com",
url="https://github.com/anentropic/django-ebaysync",
install_requires=[
"EbaySuds >= 0.3.3",
"EbaySuds >= 0.3.4",
],
)

0 comments on commit 9120063

Please sign in to comment.