aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorTom Christie2011-05-24 10:27:24 +0100
committerTom Christie2011-05-24 10:27:24 +0100
commit370274f5640d55ef71422f7a2440710a43ff900e (patch)
tree2b970d3e1ad6d283050139bfe7a914bf10586963 /examples
parent698df527a3b80edbf4278ea52e88c1699b2f2256 (diff)
downloaddjango-rest-framework-370274f5640d55ef71422f7a2440710a43ff900e.tar.bz2
Allow views to return HttpResponses. Add initial() hook method
Diffstat (limited to 'examples')
-rw-r--r--examples/objectstore/views.py6
-rw-r--r--examples/pygments_api/views.py6
-rw-r--r--examples/resourceexample/views.py6
-rw-r--r--examples/sandbox/views.py4
4 files changed, 11 insertions, 11 deletions
diff --git a/examples/objectstore/views.py b/examples/objectstore/views.py
index 076e5941..19999aa9 100644
--- a/examples/objectstore/views.py
+++ b/examples/objectstore/views.py
@@ -1,7 +1,7 @@
from django.conf import settings
from django.core.urlresolvers import reverse
-from djangorestframework.views import BaseView
+from djangorestframework.views import View
from djangorestframework.response import Response
from djangorestframework import status
@@ -25,7 +25,7 @@ def remove_oldest_files(dir, max_files):
[os.remove(path) for path in ctime_sorted_paths[max_files:]]
-class ObjectStoreRoot(BaseView):
+class ObjectStoreRoot(View):
"""
Root of the Object Store API.
Allows the client to get a complete list of all the stored objects, or to create a new stored object.
@@ -51,7 +51,7 @@ class ObjectStoreRoot(BaseView):
return Response(status.HTTP_201_CREATED, self.CONTENT, {'Location': reverse('stored-object', kwargs={'key':key})})
-class StoredObject(BaseView):
+class StoredObject(View):
"""
Represents a stored object.
The object may be any picklable content.
diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py
index e6bfae48..76647107 100644
--- a/examples/pygments_api/views.py
+++ b/examples/pygments_api/views.py
@@ -5,7 +5,7 @@ from django.core.urlresolvers import reverse
from djangorestframework.resources import FormResource
from djangorestframework.response import Response
from djangorestframework.renderers import BaseRenderer
-from djangorestframework.views import BaseView
+from djangorestframework.views import View
from djangorestframework import status
from pygments.formatters import HtmlFormatter
@@ -53,7 +53,7 @@ class PygmentsFormResource(FormResource):
form = PygmentsForm
-class PygmentsRoot(BaseView):
+class PygmentsRoot(View):
"""
This example demonstrates a simple RESTful Web API aound the awesome pygments library.
This top level resource is used to create highlighted code snippets, and to list all the existing code snippets.
@@ -88,7 +88,7 @@ class PygmentsRoot(BaseView):
return Response(status.HTTP_201_CREATED, headers={'Location': reverse('pygments-instance', args=[unique_id])})
-class PygmentsInstance(BaseView):
+class PygmentsInstance(View):
"""
Simply return the stored highlighted HTML file with the correct mime type.
This Resource only renders HTML and uses a standard HTML renderer rather than the renderers.DocumentingHTMLRenderer class.
diff --git a/examples/resourceexample/views.py b/examples/resourceexample/views.py
index 70d96891..29651fbf 100644
--- a/examples/resourceexample/views.py
+++ b/examples/resourceexample/views.py
@@ -1,6 +1,6 @@
from django.core.urlresolvers import reverse
-from djangorestframework.views import BaseView
+from djangorestframework.views import View
from djangorestframework.resources import FormResource
from djangorestframework.response import Response
from djangorestframework import status
@@ -14,7 +14,7 @@ class MyFormValidation(FormResource):
form = MyForm
-class ExampleResource(BaseView):
+class ExampleResource(View):
"""
A basic read-only resource that points to 3 other resources.
"""
@@ -23,7 +23,7 @@ class ExampleResource(BaseView):
return {"Some other resources": [reverse('another-example-resource', kwargs={'num':num}) for num in range(3)]}
-class AnotherExampleResource(BaseView):
+class AnotherExampleResource(View):
"""
A basic GET-able/POST-able resource.
"""
diff --git a/examples/sandbox/views.py b/examples/sandbox/views.py
index d5b59284..1c55c28f 100644
--- a/examples/sandbox/views.py
+++ b/examples/sandbox/views.py
@@ -1,10 +1,10 @@
"""The root view for the examples provided with Django REST framework"""
from django.core.urlresolvers import reverse
-from djangorestframework.views import BaseView
+from djangorestframework.views import View
-class Sandbox(BaseView):
+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.