diff options
| author | tom christie tom@tomchristie.com | 2011-01-26 21:06:40 +0000 | 
|---|---|---|
| committer | tom christie tom@tomchristie.com | 2011-01-26 21:06:40 +0000 | 
| commit | 9adb965126366bfe4b364357f565baabd819c982 (patch) | |
| tree | f924a64d0c4c8ff023f92fd9ef035060c825f647 /examples | |
| parent | 6807cf014cb0fde611f63c64bc352038206176cc (diff) | |
| parent | 8b89d7416cf4e2396deac4ba41c23cdcdc8b9704 (diff) | |
| download | django-rest-framework-9adb965126366bfe4b364357f565baabd819c982.tar.bz2 | |
content type tunneling
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/objectstore/views.py | 14 | ||||
| -rw-r--r-- | examples/urls.py | 6 | 
2 files changed, 13 insertions, 7 deletions
| diff --git a/examples/objectstore/views.py b/examples/objectstore/views.py index 16c7f8e9..2eaadd3c 100644 --- a/examples/objectstore/views.py +++ b/examples/objectstore/views.py @@ -13,14 +13,14 @@ OBJECT_STORE_DIR = os.path.join(settings.MEDIA_ROOT, 'objectstore')  class ObjectStoreRoot(Resource):      """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.""" -    allowed_methods = ('GET', 'POST') +    allowed_methods = anon_allowed_methods = ('GET', 'POST') -    def get(self, request): +    def get(self, request, auth):          """Return a list of all the stored object URLs."""          keys = sorted(os.listdir(OBJECT_STORE_DIR))          return [self.reverse(StoredObject, key=key) for key in keys] -    def post(self, request, content): +    def post(self, request, auth, content):          """Create a new stored object, with a unique key."""          key = str(uuid.uuid1())          pathname = os.path.join(OBJECT_STORE_DIR, key) @@ -31,22 +31,22 @@ class ObjectStoreRoot(Resource):  class StoredObject(Resource):      """Represents a stored object.      The object may be any picklable content.""" -    allowed_methods = ('GET', 'PUT', 'DELETE') +    allowed_methods = anon_allowed_methods = ('GET', 'PUT', 'DELETE') -    def get(self, request, key): +    def get(self, request, auth, key):          """Return a stored object, by unpickling the contents of a locally stored file."""          pathname = os.path.join(OBJECT_STORE_DIR, key)          if not os.path.exists(pathname):              return Response(status.HTTP_404_NOT_FOUND)          return pickle.load(open(pathname, 'rb')) -    def put(self, request, content, key): +    def put(self, request, auth, content, key):          """Update/create a stored object, by pickling the request content to a locally stored file."""          pathname = os.path.join(OBJECT_STORE_DIR, key)          pickle.dump(content, open(pathname, 'wb'))          return content -    def delete(self, request, key): +    def delete(self, request, auth, key):          """Delete a stored object, by removing it's pickled file."""          pathname = os.path.join(OBJECT_STORE_DIR, key)          if not os.path.exists(pathname): diff --git a/examples/urls.py b/examples/urls.py index 3b93045d..62001016 100644 --- a/examples/urls.py +++ b/examples/urls.py @@ -4,9 +4,15 @@ from django.contrib import admin  admin.autodiscover()  urlpatterns = patterns('', +<<<<<<< local      (r'^blog-post-api/', include('blogpost.urls')),      (r'^object-store-api/', include('objectstore.urls')),      (r'^pygments-api/', include('pygments_api.urls')), +======= +    (r'pygments-example/', include('pygmentsapi.urls')), +    (r'^blog-post-example/', include('blogpost.urls')), +    (r'^object-store-example/', include('objectstore.urls')), +>>>>>>> other      (r'^admin/doc/', include('django.contrib.admindocs.urls')),      (r'^admin/', include(admin.site.urls)),  ) | 
