From c7b9100f19d7a3701b03cfca6715a9341439b9a8 Mon Sep 17 00:00:00 2001 From: Michael Ding Date: Fri, 30 Dec 2011 22:52:01 +0800 Subject: [PATCH 1/3] change the key name "field-errors" to "field_errors". as "-" is not allowed as a part of key name in javascript --- djangorestframework/resources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/djangorestframework/resources.py b/djangorestframework/resources.py index bf9af6f04..68b285b91 100644 --- a/djangorestframework/resources.py +++ b/djangorestframework/resources.py @@ -173,7 +173,7 @@ class FormResource(Resource): field_errors[key] = [u'This field does not exist.'] if field_errors: - detail[u'field-errors'] = field_errors + detail[u'field_errors'] = field_errors # Return HTTP 400 response (BAD REQUEST) raise ErrorResponse(400, detail) From 904f197474ad3561d3d273961a70ab19d8175aaf Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 30 Dec 2011 15:32:49 +0000 Subject: [PATCH 2/3] Replace field-errors with field_errors --- djangorestframework/tests/validators.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/djangorestframework/tests/validators.py b/djangorestframework/tests/validators.py index 1f696422e..18c8c3137 100644 --- a/djangorestframework/tests/validators.py +++ b/djangorestframework/tests/validators.py @@ -149,7 +149,7 @@ class TestFormValidation(TestCase): try: validator.validate_request(content, None) except ErrorResponse, exc: - self.assertEqual(exc.response.raw_content, {'field-errors': {'qwerty': ['This field is required.']}}) + self.assertEqual(exc.response.raw_content, {'field_errors': {'qwerty': ['This field is required.']}}) else: self.fail('ResourceException was not raised') #pragma: no cover @@ -159,7 +159,7 @@ class TestFormValidation(TestCase): try: validator.validate_request(content, None) except ErrorResponse, exc: - self.assertEqual(exc.response.raw_content, {'field-errors': {'qwerty': ['This field is required.']}}) + self.assertEqual(exc.response.raw_content, {'field_errors': {'qwerty': ['This field is required.']}}) else: self.fail('ResourceException was not raised') #pragma: no cover @@ -169,7 +169,7 @@ class TestFormValidation(TestCase): try: validator.validate_request(content, None) except ErrorResponse, exc: - self.assertEqual(exc.response.raw_content, {'field-errors': {'extra': ['This field does not exist.']}}) + self.assertEqual(exc.response.raw_content, {'field_errors': {'extra': ['This field does not exist.']}}) else: self.fail('ResourceException was not raised') #pragma: no cover @@ -179,7 +179,7 @@ class TestFormValidation(TestCase): try: validator.validate_request(content, None) except ErrorResponse, exc: - self.assertEqual(exc.response.raw_content, {'field-errors': {'qwerty': ['This field is required.'], + self.assertEqual(exc.response.raw_content, {'field_errors': {'qwerty': ['This field is required.'], 'extra': ['This field does not exist.']}}) else: self.fail('ResourceException was not raised') #pragma: no cover From b8bfebc83719a7c286fee413bb44fffedac1a8d0 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 30 Dec 2011 15:33:08 +0000 Subject: [PATCH 3/3] ep.io fixes --- examples/epio.ini | 3 ++- examples/objectstore/views.py | 3 +++ examples/settings.py | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/epio.ini b/examples/epio.ini index 00a90bce1..4e61a42d0 100644 --- a/examples/epio.ini +++ b/examples/epio.ini @@ -42,11 +42,12 @@ postgres = true # to the real file 'configs/epio.py': # config.py = configs/epio.py +media/ = %(data_directory)s/ # #### If you're using Django, you'll want to uncomment some or all of these lines #### # [django] # # Path to your project root, relative to this directory. -# base = . +# base = . # # [static] # Serve the admin media diff --git a/examples/objectstore/views.py b/examples/objectstore/views.py index 2a2225293..8f997d7ef 100644 --- a/examples/objectstore/views.py +++ b/examples/objectstore/views.py @@ -13,6 +13,9 @@ import operator OBJECT_STORE_DIR = os.path.join(settings.MEDIA_ROOT, 'objectstore') MAX_FILES = 10 +if not os.path.exists(OBJECT_STORE_DIR): + os.makedirs(OBJECT_STORE_DIR) + def remove_oldest_files(dir, max_files): """ diff --git a/examples/settings.py b/examples/settings.py index 4438bb849..e12b7f3fe 100644 --- a/examples/settings.py +++ b/examples/settings.py @@ -1,4 +1,5 @@ # Settings for djangorestframework examples project +import os DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -46,7 +47,7 @@ USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/" # NOTE: Some of the djangorestframework examples use MEDIA_ROOT to store content. -MEDIA_ROOT = 'media/' +MEDIA_ROOT = os.path.join(os.getenv('EPIO_DATA_DIRECTORY', '.'), 'media') # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases).