debian/0000775000000000000000000000000012350574166007201 5ustar debian/control0000664000000000000000000000311712350573641010603 0ustar Source: python-django-piston Section: python Priority: optional Maintainer: Ubuntu Developers XSBC-Original-Maintainer: Debian Python Modules Team Uploaders: Michael Ziegler Build-Depends: debhelper (>= 7.0.50~), python-all (>=2.6.6-3~), python-setuptools Standards-Version: 3.9.5 Homepage: http://bitbucket.org/jespern/django-piston/wiki/ Vcs-Svn: svn://anonscm.debian.org/python-modules/packages/python-django-piston/trunk/ Vcs-Browser: http://anonscm.debian.org/viewvc/python-modules/packages/python-django-piston/trunk/ X-Python-Version: >= 2.6 Package: python-django-piston Architecture: all Depends: ${misc:Depends}, ${python:Depends}, python-django (>= 1.1), python-oauth (>= 1.0.1), python-decorator Suggests: python-yaml Description: Django mini-framework creating RESTful APIs Piston is a relatively small Django application that lets you create application programming interfaces (API) for your sites. . It has several unique features: . * Ties into Django's internal mechanisms. * Supports OAuth out of the box (as well as Basic/Digest or custom auth). * Doesn't require tying to models, allowing arbitrary resources. * Speaks JSON, YAML, Python Pickle & XML (and HATEOAS). * Ships with a convenient reusable library in Python. * Respects and encourages proper use of HTTP (status codes, ...). * Has built in (optional) form validation (via Django), throttling, etc. * Supports streaming, with a small memory footprint. * Stays out of your way. debian/source/0000775000000000000000000000000012342421437010472 5ustar debian/source/format0000664000000000000000000000001411340516104011671 0ustar 3.0 (quilt) debian/changelog0000664000000000000000000000463312350574165011060 0ustar python-django-piston (0.2.3-2ubuntu1) utopic; urgency=medium * debian/control: Re-add missing Depends on python-django (>= 1.1), python-oauth (>= 1.0.1), python-decorator (LP: #1330498) -- Andres Rodriguez Thu, 19 Jun 2014 10:45:30 -0400 python-django-piston (0.2.3-2) unstable; urgency=low * Team upload. [ Jakub Wilk ] * Use canonical URIs for Vcs-* fields. * Remove DM-Upload-Allowed; it's no longer used by the archive software. [ Christophe Siraut ] * Enable django 1.4 compatibility. (Closes: #686171) - 02-correct-httpresponse.patch: Correctly use '_base_content_is_iter' or '_is_string' depending on the Django version - 03-django1.4-support.patch: Add support for Django 1.4. * Use dh_python2 * Bump standards version to 3.9.5 without further change * Convert copyright to machine-readable format 1.0 * Add repack script, remove lintian-overrides [ Andrew Starr-Bochicchio ] * Cherry-pick patches from Ubuntu and upstream for Django 1.5 and 1.6 compatability: - 04-json-compat-django1.5.patch: Use json instead of simplejson for Django 1.5. (LP: #1184219) - 05-compat-django1.5-httpresponsewrapper.patch: Compatibility with Django 1.5 for HttpResponseWrapper. (LP: #1185012) - 06-django1.6-wsgirequest-compat.patch: Compatibility with Django 1.6 for WSGIRequest. (LP: #1256957) -- Andrew Starr-Bochicchio Sat, 31 May 2014 14:43:42 -0400 python-django-piston (0.2.3-1) unstable; urgency=low * New upstream release. * Remove the security patches as they have been applied upstream. * Adapt 01-fix-oauth-import.diff to reflect upstream changes. -- Michael Ziegler Sat, 12 Nov 2011 12:05:07 +0100 python-django-piston (0.2.2-2) unstable; urgency=low [ Michael Ziegler ] * Bump Standards Version to 3.9.2. * Remove reference to /usr/share/common-licenses/BSD and strip trailing whitespace in copyright. * Fix a copy-paste error in copyright. * Fix a security issue in the YAML emitter. * Disable the pickle loader due to security concerns (Closes: #646517). [ Luca Falavigna ] * Enable DM-Upload-Allowed field. -- Michael Ziegler Tue, 01 Nov 2011 19:37:58 +0100 python-django-piston (0.2.2-1) unstable; urgency=low * Initial release (Closes: #570919) -- Michael Ziegler Thu, 10 Jun 2010 10:40:58 +0200 debian/patches/0000775000000000000000000000000012342421437010621 5ustar debian/patches/04-json-compat-django1.5.patch0000664000000000000000000000410712342416666016013 0ustar From: Luke Plant Subject: Compatibility fix for JSON emitter with Django 1.5 Fixes compatibility with Django 1.5 to use json instead of simplejson due to deprecation. Origin: https://bitbucket.org/jespern/django-piston/pull-request/25/compatibility-fix-for-json-emitter-with Bug-Ubuntu: https://launchpad.net/bugs/1184219 --- python-django-piston-0.2.3.orig/piston/emitters.py 2013-05-28 11:49:03.230954662 -0400 +++ python-django-piston-0.2.3/piston/emitters.py 2013-05-28 11:50:19.151073326 -0400 @@ -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 @@ -388,7 +397,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): @@ -397,7 +406,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): """ debian/patches/03-django1.4-support.patch0000664000000000000000000000446012326743330015266 0ustar 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 = ( debian/patches/01-fix-oauth-import.diff0000664000000000000000000000222711657465704015125 0ustar Description: Fix the oauth import to work correctly with the python-oauth Debian package. Forwarded: not-needed Author: Michael Ziegler Index: python-django-piston-0.2.3/piston/authentication.py =================================================================== --- python-django-piston-0.2.3.orig/piston/authentication.py 2011-11-01 14:52:13.000000000 +0100 +++ python-django-piston-0.2.3/piston/authentication.py 2011-11-12 13:50:23.899726540 +0100 @@ -1,6 +1,6 @@ import binascii -import oauth +from oauth import oauth from django.http import HttpResponse, HttpResponseRedirect from django.contrib.auth.models import User, AnonymousUser from django.contrib.auth.decorators import login_required Index: python-django-piston-0.2.3/piston/store.py =================================================================== --- python-django-piston-0.2.3.orig/piston/store.py 2011-11-01 14:52:13.000000000 +0100 +++ python-django-piston-0.2.3/piston/store.py 2011-11-12 13:50:23.900726539 +0100 @@ -1,4 +1,4 @@ -import oauth +from oauth import oauth from models import Nonce, Token, Consumer from models import generate_random, VERIFIER_SIZE debian/patches/06-django1.6-wsgirequest-compat.patch0000664000000000000000000000157712342416666017437 0ustar From: Raphael Badin Subject: Compatibility fix for WSGIRequest with Django 1.6 Fixes compatibility with Django 1.6 to return the correct data on a WSGIRequest. Origin: https://bitbucket.org/jespern/django-piston/issue/235/attributeerror-wsgirequest-object-has-no Bug-Ubuntu: https://launchpad.net/bugs/1256957 --- python-django-piston-0.2.3.orig/piston/utils.py 2013-12-02 13:31:56.000000000 -0500 +++ python-django-piston-0.2.3/piston/utils.py 2013-12-02 13:35:30.358433201 -0500 @@ -269,7 +269,7 @@ if loadee: try: - self.request.data = loadee(self.request.raw_post_data) + self.request.data = loadee(self.request.body) # Reset both POST and PUT from request, as its # misleading having their presence around. debian/patches/02-correct-httpresponse.patch0000664000000000000000000001105412326743330016260 0ustar 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) debian/patches/05-compat-django1.5-httpresponsewrapper.patch0000664000000000000000000000216012342416666021177 0ustar From: Andrey Kuchev Subject: Added compatibility with Django v1.5 for HttpResponseWrapper class Add compatibility for django 1.5 due to HttpResponse._get_content not existing in Django 1.5 Origin: https://bitbucket.org/jespern/django-piston/pull-request/34/added-compatibility-with-django-v15-for Bug-Ubuntu: https://launchpad.net/bugs/1185012 --- python-django-piston-0.2.3.orig/piston/utils.py 2013-05-28 11:45:31.666460424 -0400 +++ python-django-piston-0.2.3/piston/utils.py 2013-05-28 11:48:26.590875780 -0400 @@ -77,7 +77,15 @@ else: self._is_string = is_string - content = property(HttpResponse._get_content, _set_content) + if django.VERSION >= (1, 5): + # HttpResponse._get_content does not exists in Django 1.5 + + @HttpResponse.content.setter + def content(self, content): + self._set_content(content) + + else: + content = property(HttpResponse._get_content, _set_content) return HttpResponseWrapper(r, content_type='text/plain', status=c) debian/patches/series0000664000000000000000000000030512342416666012044 0ustar 01-fix-oauth-import.diff 02-correct-httpresponse.patch 03-django1.4-support.patch 04-json-compat-django1.5.patch 05-compat-django1.5-httpresponsewrapper.patch 06-django1.6-wsgirequest-compat.patch debian/docs0000664000000000000000000000001411340516104010031 0ustar AUTHORS.txt debian/repack.sh0000775000000000000000000000205612333154406011000 0ustar #!/bin/sh # Repackage upstream source to exclude non-distributable files # should be called as "repack.sh --upstream-source # (for example, via uscan) set -e set -u VER="$2debian" FILE="$3" PKG=`dpkg-parsechangelog|grep ^Source:|sed 's/^Source: //'` REPACK_DIR="$PKG-$VER.orig" # DevRef ยง 6.7.8.2 DEST_DIR=$(dirname "$FILE") echo -e "\nRepackaging $FILE\n" DIR=`mktemp -d ./tmpRepackXXXXXX` trap "rm -rf \"$DIR\"" QUIT INT EXIT # Create an extra directory to cope with rootless tarballs UP_BASE="$DIR/unpack" mkdir "$UP_BASE" tar xjf "$FILE" -C "$UP_BASE" if [ `ls -1 "$UP_BASE" | wc -l` -eq 1 ]; then # Tarball does contain a root directory UP_BASE="$UP_BASE/`ls -1 "$UP_BASE"`" fi ## Remove stuff find $UP_BASE -name ".hg*" -exec rm {} \; ## End mv "$UP_BASE" "$DIR/$REPACK_DIR" # Using a pipe hides tar errors! tar cfC "$DIR/repacked.tar" "$DIR" "$REPACK_DIR" gzip -9 < "$DIR/repacked.tar" > "$DIR/repacked.tar.gz" FILE="${DEST_DIR}/${PKG}_${VER}.orig.tar.gz" mv "$DIR/repacked.tar.gz" "$FILE" echo "*** $FILE repackaged" debian/rules0000775000000000000000000000043612333151130010243 0ustar #!/usr/bin/make -f # -*- makefile -*- #export DH_VERBOSE=1 override_dh_auto_install: dh_auto_install rm debian/python-django-piston/usr/lib/python*/*-packages/piston/oauth.py rm debian/python-django-piston/usr/lib/python*/*-packages/piston/decorator.py %: dh $@ --with python2 debian/watch0000664000000000000000000000037212333154406010224 0ustar version=3 opts=filenamemangle=s#/jespern/django-piston/get/([\d\.]*)\.tar\.bz2#python-django-piston_$1\.orig\.tar\.bz2# \ http://bitbucket.org/jespern/django-piston/downloads/ \ /jespern/django-piston/get/([\d\.]*)\.tar\.bz2 \ debian repack.sh debian/copyright0000664000000000000000000001276712333151130011130 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: django-piston Source: http://bitbucket.org/jespern/django-piston/ Files: * Copyright: 2008-2010 Jesper Noehr License: BSD Files: piston/decorator.py Copyright: 2007-2010 Michele Simionato License: BSD-2-clause Files: tests/bootstrap.py Copyright: 2006 the Zope Corporation License: ZPL-2.1 Files: debian/* Copyright: 2010 Michael Ziegler License: BSD License: BSD Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: BSD-2-clause Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . THIS SOFTWARE IS PROVIDED BY AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. License: ZPL-2.1 Zope Public License (ZPL) Version 2.1 . A copyright notice accompanies this license document that identifies the copyright holders. . This license has been certified as open source. It has also been designated as GPL compatible by the Free Software Foundation (FSF). . Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: . 1. Redistributions in source code must retain the accompanying copyright notice, this list of conditions, and the following disclaimer. . 2. Redistributions in binary form must reproduce the accompanying copyright notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. . 3. Names of the copyright holders must not be used to endorse or promote products derived from this software without prior written permission from the copyright holders. . 4. The right to distribute this software or to use it for any purpose does not give you the right to use Servicemarks (sm) or Trademarks (tm) of the copyright holders. Use of them is covered by separate agreement with the copyright holders. . 5. If any files are modified, you must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. . Disclaimer . THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. debian/compat0000664000000000000000000000000211340516104010361 0ustar 7