[snowy] Apply piston fix to make all handlers csrf-exempt
- From: Sanford Armstrong <sharm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [snowy] Apply piston fix to make all handlers csrf-exempt
- Date: Thu, 16 Sep 2010 13:47:08 +0000 (UTC)
commit 04c448f651df6854b9f9a01f6f5a43281c3bf670
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Tue Sep 14 00:07:45 2010 -0700
Apply piston fix to make all handlers csrf-exempt
http://bitbucket.org/jespern/django-piston/changeset/87c0fcfb7465
api/urls.py | 8 --------
lib/piston/resource.py | 1 +
2 files changed, 1 insertions(+), 8 deletions(-)
---
diff --git a/api/urls.py b/api/urls.py
index 5bd2377..524beb8 100644
--- a/api/urls.py
+++ b/api/urls.py
@@ -26,18 +26,10 @@ auth = HttpBasicAuthentication(realm='Snowy')
authoauth = OAuthAuthentication(realm='Snowy')
ad = {'authentication': authoauth}
-""" piston resources are marked csrf_exempt to ensure the the django
-CsrfMiddleware doesn't interfere with POST requests
-http://bitbucket.org/jespern/django-piston/issue/82/post-requests-fail-when-using-django-trunk """
-
root_handler = Resource(handler=RootHandler, **ad)
-root_handler.csrf_exempt = getattr(root_handler.handler, 'csrf_exempt', True)
user_handler = Resource(UserHandler)
-user_handler.csrf_exempt = getattr(user_handler.handler, 'csrf_exempt', True)
notes_handler = Resource(handler=NotesHandler, **ad)
-notes_handler.csrf_exempt = getattr(notes_handler.handler, 'csrf_exempt', True)
note_handler = Resource(handler=NoteHandler, **ad)
-note_handler.csrf_exempt = getattr(note_handler.handler, 'csrf_exempt', True)
urlpatterns = patterns('',
# 1.0 API methods
diff --git a/lib/piston/resource.py b/lib/piston/resource.py
index c63fd54..5bafa66 100644
--- a/lib/piston/resource.py
+++ b/lib/piston/resource.py
@@ -34,6 +34,7 @@ class Resource(object):
raise AttributeError, "Handler not callable."
self.handler = handler()
+ self.csrf_exempt = getattr(self.handler, 'csrf_exempt', True)
if not authentication:
self.authentication = (NoAuthentication(),)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]