[Python-modules-commits] r28660 - in packages/python-django-piston/trunk/debian (4 files)

tobald-guest at users.alioth.debian.org tobald-guest at users.alioth.debian.org
Sat Apr 26 14:46:49 UTC 2014


    Date: Saturday, April 26, 2014 @ 14:46:48
  Author: tobald-guest
Revision: 28660

* Enable django 1.4 compatibility. (Closes: #686171)
* Non-maintainer upload.

Added:
  packages/python-django-piston/trunk/debian/patches/02-correct-httpresponse.patch
  packages/python-django-piston/trunk/debian/patches/03-django1.4-support.patch
Modified:
  packages/python-django-piston/trunk/debian/changelog
  packages/python-django-piston/trunk/debian/patches/series

Modified: packages/python-django-piston/trunk/debian/changelog
===================================================================
--- packages/python-django-piston/trunk/debian/changelog	2014-04-26 11:58:46 UTC (rev 28659)
+++ packages/python-django-piston/trunk/debian/changelog	2014-04-26 14:46:48 UTC (rev 28660)
@@ -1,11 +1,16 @@
-python-django-piston (0.2.3-2) UNRELEASED; urgency=low
+python-django-piston (0.2.3-1+nmu1) unstable; urgency=low
 
+  [ Jakub Wilk ]
   * Use canonical URIs for Vcs-* fields.
   * Remove DM-Upload-Allowed; it's no longer used by the archive
     software.
 
- -- Jakub Wilk <jwilk at debian.org>  Sun, 05 May 2013 18:40:53 +0200
+  [ Christophe Siraut ]
+  * Enable django 1.4 compatibility. (Closes: #686171)
+  * Non-maintainer upload.
 
+ -- Christophe Siraut <d at tobald.eu.org>  Sat, 26 Apr 2014 16:32:44 +0200
+
 python-django-piston (0.2.3-1) unstable; urgency=low
 
   * New upstream release.

Added: packages/python-django-piston/trunk/debian/patches/02-correct-httpresponse.patch
===================================================================
--- packages/python-django-piston/trunk/debian/patches/02-correct-httpresponse.patch	                        (rev 0)
+++ packages/python-django-piston/trunk/debian/patches/02-correct-httpresponse.patch	2014-04-26 14:46:48 UTC (rev 28660)
@@ -0,0 +1,103 @@
+From: Andi Albrecht
+Subject: Use _base_content_is_iter or _is_string
+ Correctly use _base_content_is_iter or _is_string on HttpResponse depending on
+ Django version.
+Origin: upstream, https://bitbucket.org/jespern/django-piston/changeset/3a0d021dd042
+
+--- python-django-piston-0.2.3.orig/piston/resource.py	2011-11-01 09:52:13.000000000 -0400
++++ python-django-piston-0.2.3/piston/resource.py	2012-06-27 12:43:41.424489361 -0400
+@@ -1,5 +1,6 @@
+ import sys, inspect
+ 
++import django
+ from django.http import (HttpResponse, Http404, HttpResponseNotAllowed,
+     HttpResponseForbidden, HttpResponseServerError)
+ from django.views.debug import ExceptionReporter
+@@ -181,13 +182,15 @@
+         # If we're looking at a response object which contains non-string
+         # content, then assume we should use the emitter to format that 
+         # content
+-        if isinstance(result, HttpResponse) and not result._is_string:
++        if self._use_emitter(result):
+             status_code = result.status_code
+-            # Note: We can't use result.content here because that method attempts
+-            # to convert the content into a string which we don't want. 
+-            # when _is_string is False _container is the raw data
++            # Note: We can't use result.content here because that
++            # method attempts to convert the content into a string
++            # which we don't want.  when
++            # _is_string/_base_content_is_iter is False _container is
++            # the raw data
+             result = result._container
+-     
++
+         srl = emitter(result, typemapper, handler, fields, anonymous)
+ 
+         try:
+@@ -212,6 +215,16 @@
+             return e.response
+ 
+     @staticmethod
++    def _use_emitter(result):
++        """True iff result is a HttpResponse and contains non-string content."""
++        if not isinstance(result, HttpResponse):
++            return False
++        elif django.VERSION >= (1, 4):
++            return not result._base_content_is_iter
++        else:
++            return result._is_string
++
++    @staticmethod
+     def cleanup_request(request):
+         """
+         Removes `oauth_` keys from various dicts on the
+--- python-django-piston-0.2.3.orig/piston/utils.py	2011-11-01 09:52:13.000000000 -0400
++++ python-django-piston-0.2.3/piston/utils.py	2012-06-27 12:43:41.424489361 -0400
+@@ -1,4 +1,6 @@
+ import time
++
++import django
+ from django.http import HttpResponseNotAllowed, HttpResponseForbidden, HttpResponse, HttpResponseBadRequest
+ from django.core.urlresolvers import reverse
+ from django.core.cache import cache
+@@ -50,24 +52,30 @@
+ 
+         class HttpResponseWrapper(HttpResponse):
+             """
+-            Wrap HttpResponse and make sure that the internal _is_string 
+-            flag is updated when the _set_content method (via the content 
+-            property) is called
++            Wrap HttpResponse and make sure that the internal
++            _is_string/_base_content_is_iter flag is updated when the
++            _set_content method (via the content property) is called
+             """
+             def _set_content(self, content):
+                 """
+-                Set the _container and _is_string properties based on the 
+-                type of the value parameter. This logic is in the construtor
+-                for HttpResponse, but doesn't get repeated when setting 
+-                HttpResponse.content although this bug report (feature request)
+-                suggests that it should: http://code.djangoproject.com/ticket/9403 
++                Set the _container and _is_string /
++                _base_content_is_iter properties based on the type of
++                the value parameter. This logic is in the construtor
++                for HttpResponse, but doesn't get repeated when
++                setting HttpResponse.content although this bug report
++                (feature request) suggests that it should:
++                http://code.djangoproject.com/ticket/9403
+                 """
++                is_string = False
+                 if not isinstance(content, basestring) and hasattr(content, '__iter__'):
+                     self._container = content
+-                    self._is_string = False
+                 else:
+                     self._container = [content]
+-                    self._is_string = True
++                    is_string = True
++                if django.VERSION >= (1, 4):
++                    self._base_content_is_iter = not is_string
++                else:
++                    self._is_string = is_string
+ 
+             content = property(HttpResponse._get_content, _set_content)            
+ 

Added: packages/python-django-piston/trunk/debian/patches/03-django1.4-support.patch
===================================================================
--- packages/python-django-piston/trunk/debian/patches/03-django1.4-support.patch	                        (rev 0)
+++ packages/python-django-piston/trunk/debian/patches/03-django1.4-support.patch	2014-04-26 14:46:48 UTC (rev 28660)
@@ -0,0 +1,62 @@
+From: Andi Albrecht
+Subject: Piston now supports Django 1.4
+ Support for Django 1.4
+Origin: upstream, https://bitbucket.org/jespern/django-piston/changeset/7c90898072ce
+Bug: https://bitbucket.org/jespern/django-piston/issue/214/django-14-compatibility
+
+--- python-django-piston-0.2.3.orig/piston/resource.py	2012-06-27 12:43:54.384489691 -0400
++++ python-django-piston-0.2.3/piston/resource.py	2012-06-27 12:45:00.316491380 -0400
+@@ -73,7 +73,7 @@
+         `Resource` subclass.
+         """
+         resp = rc.BAD_REQUEST
+-        resp.write(' '+str(e.form.errors))
++        resp.write(u' '+unicode(e.form.errors))
+         return resp
+ 
+     @property
+@@ -220,9 +220,9 @@
+         if not isinstance(result, HttpResponse):
+             return False
+         elif django.VERSION >= (1, 4):
+-            return not result._base_content_is_iter
++            return result._base_content_is_iter
+         else:
+-            return result._is_string
++            return not result._is_string
+ 
+     @staticmethod
+     def cleanup_request(request):
+--- python-django-piston-0.2.3.orig/piston/tests.py	2011-11-01 09:52:13.000000000 -0400
++++ python-django-piston-0.2.3/piston/tests.py	2012-06-27 12:45:00.320491380 -0400
+@@ -1,4 +1,5 @@
+ # Django imports
++import django
+ from django.core import mail
+ from django.contrib.auth.models import User
+ from django.conf import settings
+@@ -100,7 +101,8 @@
+          response = resource(request, emitter_format='json')
+ 
+          self.assertEquals(201, response.status_code)
+-         self.assertTrue(response._is_string, "Expected response content to be a string")
++         is_string = (not response._base_content_is_iter) if django.VERSION >= (1,4) else response._is_string
++         self.assert_(is_string, "Expected response content to be a string")
+ 
+          # compare the original data dict with the json response 
+          # converted to a dict
+--- python-django-piston-0.2.3.orig/tests/test_project/settings.py	2011-11-01 09:52:13.000000000 -0400
++++ python-django-piston-0.2.3/tests/test_project/settings.py	2012-06-27 12:45:00.320491380 -0400
+@@ -1,5 +1,12 @@
+ import os
+ DEBUG = True
++DATABASES = {
++    'default':
++        {
++        'ENGINE': 'django.db.backends.sqlite3',
++        'NAME': '/tmp/piston.db'
++    }
++}
+ DATABASE_ENGINE = 'sqlite3'
+ DATABASE_NAME = '/tmp/piston.db'
+ INSTALLED_APPS = (

Modified: packages/python-django-piston/trunk/debian/patches/series
===================================================================
--- packages/python-django-piston/trunk/debian/patches/series	2014-04-26 11:58:46 UTC (rev 28659)
+++ packages/python-django-piston/trunk/debian/patches/series	2014-04-26 14:46:48 UTC (rev 28660)
@@ -1 +1,3 @@
 01-fix-oauth-import.diff
+02-correct-httpresponse.patch
+03-django1.4-support.patch




More information about the Python-modules-commits mailing list