Commits

Remco Wendt committed fc1da54

Changed content_length method to be a classmethod, renamend self to cls for classmethods as is the default naming in python

Comments (0)

Files changed (1)

examples/blogserver/api/handlers.py

     fields = ('id', 'title', 'content', 'created_on')
 
     @classmethod
-    def resource_uri(self):
+    def resource_uri(cls):
         return ('blogposts', [ 'format', ])
 
 class BlogpostHandler(BaseHandler):
     anonymous = AnonymousBlogpostHandler
     fields = ('title', 'content', ('author', ('username',)), 
               'created_on', 'content_length')
-    
+
+    @classmethod
+    def content_length(cls, blogpost):
+        return len(blogpost.content)
+
+    @classmethod
+    def resource_uri(cls):
+        return ('blogposts', [ 'format', ])
+
     def read(self, request, title=None):
         """
         Returns a blogpost, if `title` is given,
             return base.get(title=title)
         else:
             return base.all()
-    
-    def content_length(self, blogpost):
-        return len(blogpost.content)
-        
+
     @require_extended
     def create(self, request):
         """
             post.save()
             
             return post
-    
-    @classmethod
-    def resource_uri(self):
-        return ('blogposts', [ 'format', ])