From c0bf45d82a329214d0dc7b4495548563ac97a2cc Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Mon, 12 Dec 2011 08:51:02 -0600 Subject: [PATCH 1/7] drop yaml fixture and replace with json --- .../fixtures/initial_data.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/permissionsexample/fixtures/initial_data.json diff --git a/examples/permissionsexample/fixtures/initial_data.json b/examples/permissionsexample/fixtures/initial_data.json new file mode 100644 index 000000000..153de8e85 --- /dev/null +++ b/examples/permissionsexample/fixtures/initial_data.json @@ -0,0 +1,18 @@ +[ + { + "pk": 2, + "model": "auth.user", + "fields": { + "username": "test", + "first_name": "", + "last_name": "", + "is_active": true, + "is_superuser": false, + "is_staff": false, + "groups": [], + "user_permissions": [], + "password": "sha1$b3dff$671b4ab97f2714446da32670d27576614e176758", + "email": "" + } + } +] From cb8931a014af506c173e9d3b596e2f4aa51600cc Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 12 Dec 2011 15:33:45 +0000 Subject: [PATCH 2/7] Typo. --- djangorestframework/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangorestframework/views.py b/djangorestframework/views.py index 0a3594047..4cc2c7cb0 100644 --- a/djangorestframework/views.py +++ b/djangorestframework/views.py @@ -156,7 +156,7 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView): # Always add these headers. # # TODO - this isn't actually the correct way to set the vary header, - # also it's currently sub-obtimal for HTTP caching - need to sort that out. + # also it's currently sub-optimal for HTTP caching - need to sort that out. response.headers['Allow'] = ', '.join(self.allowed_methods) response.headers['Vary'] = 'Authenticate, Accept' From 51c53a8a5c5141f47f3cefab5d3353250422cab3 Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Mon, 12 Dec 2011 09:41:18 -0600 Subject: [PATCH 3/7] now really drop the yaml file --- .../permissionsexample/fixtures/initial_data.yaml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 examples/permissionsexample/fixtures/initial_data.yaml diff --git a/examples/permissionsexample/fixtures/initial_data.yaml b/examples/permissionsexample/fixtures/initial_data.yaml deleted file mode 100644 index 22276ec2b..000000000 --- a/examples/permissionsexample/fixtures/initial_data.yaml +++ /dev/null @@ -1,12 +0,0 @@ -- fields: - first_name: '' - groups: [] - is_active: true - is_staff: true - is_superuser: true - last_name: '' - password: sha1$b3dff$671b4ab97f2714446da32670d27576614e176758 - user_permissions: [] - username: test - model: auth.user - pk: 2 From 1686419aadefb1aa98578ade309979f867cb1220 Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Mon, 12 Dec 2011 19:56:39 +0100 Subject: [PATCH 4/7] less is more; dropped the mention of Bitbucket repo --- README.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.rst b/README.rst index 6b215c69b..092010b64 100644 --- a/README.rst +++ b/README.rst @@ -30,11 +30,6 @@ To clone the project from GitHub using git:: git clone git@github.com:tomchristie/django-rest-framework.git -To clone the project from Bitbucket using mercurial:: - - hg clone https://tomchristie@bitbucket.org/tomchristie/django-rest-framework - - To install django-rest-framework in a virtualenv environment:: cd django-rest-framework From ac18bea009e93044e47b4f7a6286f0e1414128c3 Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Mon, 12 Dec 2011 20:53:10 +0100 Subject: [PATCH 5/7] deleted reference to bitbucket from the docs --- docs/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 0b8b535e0..309effab6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -52,7 +52,6 @@ You can install Django REST framework using ``pip`` or ``easy_install``:: Or get the latest development version using mercurial or git:: - hg clone https://bitbucket.org/tomchristie/django-rest-framework git clone git@github.com:tomchristie/django-rest-framework.git Or you can `download the current release `_. From 8cd7ab14228cdfc308a1e4796016b5c00bdf8d8e Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Mon, 12 Dec 2011 22:20:09 +0100 Subject: [PATCH 6/7] typo --- examples/sandbox/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sandbox/views.py b/examples/sandbox/views.py index 29f2e3ce6..ecf62165b 100644 --- a/examples/sandbox/views.py +++ b/examples/sandbox/views.py @@ -7,7 +7,7 @@ from djangorestframework.views import View class Sandbox(View): """This is the sandbox for the examples provided with [Django REST framework](http://django-rest-framework.org). - These examples are provided to help you get a better idea of the some of the features of RESTful APIs created using the framework. + These examples are provided to help you get a better idea of some of the features of RESTful APIs created using the framework. All the example APIs allow anonymous access, and can be navigated either through the browser or from the command line... From 2be350293bdd7a3e64e8f43a4b8424e277b7dc66 Mon Sep 17 00:00:00 2001 From: Marco Westerhof Date: Tue, 13 Dec 2011 11:14:23 +0100 Subject: [PATCH 7/7] fix for unhandled _SkipField exception in Serializer.serialize_model --- djangorestframework/serializer.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/djangorestframework/serializer.py b/djangorestframework/serializer.py index 55b84df16..bb77ef7dc 100644 --- a/djangorestframework/serializer.py +++ b/djangorestframework/serializer.py @@ -229,21 +229,21 @@ class Serializer(object): # serialize each required field for fname in fields: - if hasattr(self, smart_str(fname)): - # check first for a method 'fname' on self first - meth = getattr(self, fname) - if inspect.ismethod(meth) and len(inspect.getargspec(meth)[0]) == 2: - obj = meth(instance) - elif hasattr(instance, '__contains__') and fname in instance: - # check for a key 'fname' on the instance - obj = instance[fname] - elif hasattr(instance, smart_str(fname)): - # finally check for an attribute 'fname' on the instance - obj = getattr(instance, fname) - else: - continue - try: + if hasattr(self, smart_str(fname)): + # check first for a method 'fname' on self first + meth = getattr(self, fname) + if inspect.ismethod(meth) and len(inspect.getargspec(meth)[0]) == 2: + obj = meth(instance) + elif hasattr(instance, '__contains__') and fname in instance: + # check for a key 'fname' on the instance + obj = instance[fname] + elif hasattr(instance, smart_str(fname)): + # finally check for an attribute 'fname' on the instance + obj = getattr(instance, fname) + else: + continue + key = self.serialize_key(fname) val = self.serialize_val(fname, obj) data[key] = val