[python-django-piston] Django 1.5 compatibility
Miro Hrončok
churchyard at fedoraproject.org
Wed Jun 5 11:47:26 UTC 2013
commit e2761f0fc7e9613ec04879b4f9021b306cda1b8e
Author: Miro Hrončok <miro at hroncok.cz>
Date: Wed Jun 5 13:28:43 2013 +0200
Django 1.5 compatibility
python-django-piston-django15-json.patch | 53 ++++++++++++++++++++++++++++++
python-django-piston.spec | 13 ++++++--
2 files changed, 63 insertions(+), 3 deletions(-)
---
diff --git a/python-django-piston-django15-json.patch b/python-django-piston-django15-json.patch
new file mode 100644
index 0000000..1420a3d
--- /dev/null
+++ b/python-django-piston-django15-json.patch
@@ -0,0 +1,53 @@
+# HG changeset patch
+# User Luke Plant <L.Plant.98 at cantab.net>
+# Date 1339524020 -3600
+# Node ID 40645e760ea2cb9a37d87c9352607b3fa7fac346
+# Parent 7c90898072ce9462a6023bbec5d408ad097a362b
+Compatibility fix for JSON emitter with Django 1.5
+
+diff -r 7c90898072ce9462a6023bbec5d408ad097a362b -r 40645e760ea2cb9a37d87c9352607b3fa7fac346 piston/emitters.py
+--- a/piston/emitters.py Fri Mar 30 18:12:21 2012 -0400
++++ b/piston/emitters.py Tue Jun 12 19:00:20 2012 +0100
+@@ -22,7 +22,6 @@
+
+ from django.db.models.query import QuerySet
+ from django.db.models import Model, permalink
+-from django.utils import simplejson
+ from django.utils.xmlutils import SimplerXMLGenerator
+ from django.utils.encoding import smart_unicode
+ from django.core.urlresolvers import reverse, NoReverseMatch
+@@ -30,6 +29,16 @@
+ from django.http import HttpResponse
+ from django.core import serializers
+
++import django
++if django.VERSION >= (1, 5):
++ # In 1.5 and later, DateTimeAwareJSONEncoder inherits from json.JSONEncoder,
++ # while in 1.4 and earlier it inherits from simplejson.JSONEncoder. The two
++ # are not compatible due to keyword argument namedtuple_as_object, and we
++ # have to ensure that the 'dumps' function we use is the right one.
++ import json
++else:
++ from django.utils import simplejson as json
++
+ from utils import HttpStatusCode, Mimer
+ from validate_jsonp import is_valid_jsonp_callback_value
+
+@@ -407,7 +416,7 @@
+ """
+ def render(self, request):
+ cb = request.GET.get('callback', None)
+- seria = simplejson.dumps(self.construct(), cls=DateTimeAwareJSONEncoder, ensure_ascii=False, indent=4)
++ seria = json.dumps(self.construct(), cls=DateTimeAwareJSONEncoder, ensure_ascii=False, indent=4)
+
+ # Callback
+ if cb and is_valid_jsonp_callback_value(cb):
+@@ -416,7 +425,7 @@
+ return seria
+
+ Emitter.register('json', JSONEmitter, 'application/json; charset=utf-8')
+-Mimer.register(simplejson.loads, ('application/json',))
++Mimer.register(json.loads, ('application/json',))
+
+ class YAMLEmitter(Emitter):
+ """
diff --git a/python-django-piston.spec b/python-django-piston.spec
index d99db99..34b6e3a 100644
--- a/python-django-piston.spec
+++ b/python-django-piston.spec
@@ -1,7 +1,7 @@
%global pkgname django-piston
Name: python-django-piston
Version: 0.2.3
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: A mini-framework for Django for creating RESTful APIs
Group: Development/Languages
@@ -10,13 +10,15 @@ URL: http://bitbucket.org/jespern/django-piston/
Source: http://pypi.python.org/packages/source/d/%{pkgname}/%{pkgname}-%{version}.tar.gz
#md5=8b040d426793cf22ce89543e059cd6e1
+# https://bitbucket.org/jespern/django-piston/pull-request/25/compatibility-fix-for-json-emitter-with/diff
+Patch0: %{name}-django15-json.patch
+
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python-setuptools
BuildRequires: python-zc-buildout
-# once bug 737293 closed, reqires should be python-django
-Requires: Django
+Requires: python-django
Provides: %{pkgname} = %{version}-%{release}
Obsoletes: %{pkgname} < 0.2.3-3
@@ -27,6 +29,7 @@ create application programming interfaces (API) for your sites.
%prep
%setup -q -n %{pkgname}-%{version}
+%patch0 -p1
rm -rf django_piston.egg-info
%build
@@ -45,6 +48,10 @@ rm -rf django_piston.egg-info
%{python_sitelib}/django_piston-%{version}-py2.?-nspkg.pth
%changelog
+* Wed Jun 05 2013 Miro Hrončok <mhroncok at redhat.com> - 0.2.3-6
+- Changed Requires Django to python-django
+- Added Django 1.5 compatibility patch
+
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.2.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
More information about the scm-commits
mailing list