Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

getting the blogserver up and running with the latest code

  • Loading branch information...
commit 331d94d74cf44575ca2e3226fa81e9453075510d 1 parent 53bc18d
@jespern jespern authored
Showing with 9 additions and 15 deletions.
  1. +9 −15 examples/blogserver/api/handlers.py
View
24 examples/blogserver/api/handlers.py
@@ -3,23 +3,12 @@
from blogserver.blog.models import Blogpost
-class AnonymousBlogpostHandler(AnonymousBaseHandler):
- """
- Anonymous entrypoint for blogposts.
- """
- model = Blogpost
- fields = ('id', 'title', 'content', 'created_on')
-
- @classmethod
- def resource_uri(cls):
- return ('blogposts', [ 'format', ])
-
class BlogpostHandler(BaseHandler):
"""
Authenticated entrypoint for blogposts.
"""
model = Blogpost
- anonymous = AnonymousBlogpostHandler
+ anonymous = 'AnonymousBlogpostHandler'
fields = ('title', 'content', ('author', ('username',)),
'created_on', 'content_length')
@@ -28,8 +17,8 @@ def content_length(cls, blogpost):
return len(blogpost.content)
@classmethod
- def resource_uri(cls):
- return ('blogposts', [ 'format', ])
+ def resource_uri(cls, blogpost):
+ return ('blogposts', [ 'json', ])
def read(self, request, title=None):
"""
@@ -46,7 +35,6 @@ def read(self, request, title=None):
else:
return base.all()
- @require_extended
def create(self, request):
"""
Creates a new blogpost.
@@ -62,3 +50,9 @@ def create(self, request):
post.save()
return post
+
+class AnonymousBlogpostHandler(BlogpostHandler, AnonymousBaseHandler):
+ """
+ Anonymous entrypoint for blogposts.
+ """
+ fields = ('id', 'title', 'content', 'created_on')
Please sign in to comment.
Something went wrong with that request. Please try again.