def get_by_title(self, request, title=(str,)): query = Post.query(Post.title==title) post = query.get() if not post: raise f3.NotFoundException() if not post.key.kind() == 'Post': raise f3.InvalidRequestException() message = f3.messages.serialize(PostMessage, post) return message
def list_all(self, request): ''' return list of all posts as a PostMessage ''' posts = Post.query() if not posts: raise f3.NotFoundException() list_message = f3.messages.serialize_list(PostListMessage, posts) return list_message