File: 0002-Django-1.10-compat-from.patch

package info (click to toggle)
python-restless 2.0.1-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 484 kB
  • ctags: 445
  • sloc: python: 1,887; makefile: 149
file content (44 lines) | stat: -rw-r--r-- 1,688 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 130057ffd2fbcdfef96a4c286925b38b8f81e2e2 Mon Sep 17 00:00:00 2001
From: "W. Martin Borgert" <debacle@debian.org>
Date: Wed, 29 Jun 2016 00:33:03 +0200
Subject: =?UTF-8?q?Django=201.10=20compat=20from=0Ahttps://github.com/toas?=
 =?UTF-8?q?tdriven/restless/pull/75/files?=

---
 restless/dj.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/restless/dj.py b/restless/dj.py
index 3ffb778..0e68569 100644
--- a/restless/dj.py
+++ b/restless/dj.py
@@ -1,7 +1,12 @@
 import six
 
+from distutils.version import StrictVersion
+from django import get_version as get_django_version
 from django.conf import settings
-from django.conf.urls import patterns, url
+if StrictVersion(get_django_version()) >= StrictVersion('1.7.0'):
+    from django.conf.urls import url
+else:
+    from django.conf.urls import patterns, url
 from django.core.exceptions import ObjectDoesNotExist
 from django.http import HttpResponse, Http404
 from django.views.decorators.csrf import csrf_exempt
@@ -82,9 +87,12 @@ class DjangoResource(Resource):
             ``api_blogpost_list``
         :type name_prefix: string
 
-        :returns: A ``patterns`` object for ``include(...)``
+        :returns: A ``list`` or ``patterns`` object for ``include(...)``
         """
-        return patterns('',
+        urls = [
             url(r'^$', cls.as_list(), name=cls.build_url_name('list', name_prefix)),
             url(r'^(?P<pk>\d+)/$', cls.as_detail(), name=cls.build_url_name('detail', name_prefix)),
-        )
+        ]
+        if StrictVersion(get_django_version()) >= StrictVersion('1.7.0'):
+            return urls
+        return patterns('', urls[0], urls[1])