def get_by_id(post_id): s = Session() try: return s.query(Post).filter(Post.id == post_id).one() except NoResultFound: return None
def get_visible_posts(): s = Session() return s.query(Post).filter(Post.is_visible == True).\ order_by(Post.post_date.desc())
def get_by_id(comment_id): s = Session() try: return s.query(Comment).filter(Comment.id == comment_id).one() except NoResultFound: return None