class PostOutSchema(Schema): id = Integer() title = String() content = String() coins = Integer() private = Boolean() author = Nested(PublicUserOutSchema) comments = List(Nested(CommentOutSchema, exclude=("post", ))) columns = List(Nested(ColumnOutSchema, exclude=("posts", "author"))) self = ma.URLFor(".post", values=dict(post_id="<id>"))
class CommentOutSchema(Schema): id = Integer() body = String() author = Nested(PublicUserOutSchema) post = Nested(lambda: PostOutSchema(only=( "id", "title", "self", ))) replying = Nested(lambda: CommentOutSchema(exclude=("replying", ))) self = ma.URLFor(".comment", values=dict(comment_id="<id>"))
class PublicUserOutSchema(Schema): id = Integer() username = String() name = String() location = String() about_me = String() confirmed = Boolean() blocked = Boolean() member_since = DateTime() last_seen = DateTime() self = ma.URLFor(".user", values=dict(user_id="<id>"))
class ColumnOutSchema(Schema): id = Integer() name = String() author = Nested(PublicUserOutSchema) posts = List(Nested(lambda: PostOutSchema(only=("id", "title", "self")))) self = ma.URLFor(".column", values=dict(column_id="<id>"))