Commit 934feea8 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

wheezy: fix _patch_resolve to comply with Django

Class RegexURLPattern doesn't contain `_get_callback' method any more
and resolve the callback when we try to retrieve it.
parent e4a6a01b
......@@ -35,24 +35,33 @@ from django.core import urlresolvers
from django.views.decorators import csrf
from django.conf.urls.defaults import patterns
def _patch_pattern(regex_pattern):
Patch pattern callback using csrf_exempt. Enforce
RegexURLPattern callback to get resolved if required.
if hasattr(regex_pattern, "_get_callback"): # Django==1.2
if not regex_pattern._callback:
# enforce _callback resolving
regex_pattern._callback = \
regex_pattern._callback = \
def _patch_resolver(r):
Patch all patterns found in resolver with _patch_pattern
if hasattr(r, '_get_url_patterns'):
if hasattr(r, '_get_url_patterns'): # Django ==1.2
entries = r._get_url_patterns()
elif hasattr(r, 'url_patterns'):
entries = r.url_patterns
# first level view in patterns ?
entries = [r]
......@@ -65,6 +74,7 @@ def _patch_resolver(r):
def api_patterns(*args, **kwargs):
Protect all url patterns from csrf attacks.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment