diff options
| author | Sébastien Piquemal | 2012-02-23 09:01:33 +0200 |
|---|---|---|
| committer | Sébastien Piquemal | 2012-02-23 09:01:33 +0200 |
| commit | 9da1ae81dc9a056db94ea07f35478ed003fea598 (patch) | |
| tree | 2557ce0fe8be2b7febb184c3bb3da7b5289fbbe1 /examples/pygments_api/views.py | |
| parent | 242327d339fe1193a45c64cb20a2ba4c56044c3b (diff) | |
| parent | 5fd4c639d7c64572dd07dc31dcd627bed9469b05 (diff) | |
| download | django-rest-framework-9da1ae81dc9a056db94ea07f35478ed003fea598.tar.bz2 | |
merged + fixed broken test
Diffstat (limited to 'examples/pygments_api/views.py')
| -rw-r--r-- | examples/pygments_api/views.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py index 852b6730..75d36fea 100644 --- a/examples/pygments_api/views.py +++ b/examples/pygments_api/views.py @@ -1,10 +1,10 @@ from __future__ import with_statement # for python 2.5 from django.conf import settings -from django.core.urlresolvers import reverse from djangorestframework.resources import FormResource from djangorestframework.response import Response from djangorestframework.renderers import BaseRenderer +from djangorestframework.reverse import reverse from djangorestframework.views import View from djangorestframework import status @@ -61,7 +61,7 @@ class PygmentsRoot(View): Return a list of all currently existing snippets. """ unique_ids = [os.path.split(f)[1] for f in list_dir_sorted_by_ctime(HIGHLIGHTED_CODE_DIR)] - return Response([reverse('pygments-instance', args=[unique_id]) for unique_id in unique_ids]) + return Response([reverse('pygments-instance', request, args=[unique_id]) for unique_id in unique_ids]) def post(self, request): """ @@ -81,8 +81,8 @@ class PygmentsRoot(View): remove_oldest_files(HIGHLIGHTED_CODE_DIR, MAX_FILES) - self.headers['Location'] = reverse('pygments-instance', args=[unique_id]) - return Response(status=status.HTTP_201_CREATED) + location = reverse('pygments-instance', request, args=[unique_id]) + return Response(status=status.HTTP_201_CREATED, headers={'Location': location}) class PygmentsInstance(View): @@ -98,7 +98,7 @@ class PygmentsInstance(View): """ pathname = os.path.join(HIGHLIGHTED_CODE_DIR, unique_id) if not os.path.exists(pathname): - return Response(status.HTTP_404_NOT_FOUND) + return Response(status=status.HTTP_404_NOT_FOUND) return Response(open(pathname, 'r').read()) def delete(self, request, unique_id): @@ -107,6 +107,7 @@ class PygmentsInstance(View): """ pathname = os.path.join(HIGHLIGHTED_CODE_DIR, unique_id) if not os.path.exists(pathname): - return Response(status.HTTP_404_NOT_FOUND) - return Response(os.remove(pathname)) + return Response(status=status.HTTP_404_NOT_FOUND) + os.remove(pathname) + return Response() |
