def api_topic_posts(topicid): """ Display a single topic's posts. Request params: user, limit, start """ try: topicObj = Topic(g.db, topicid) except InvalidUserError: return not_found() postList = PostList(g.db).topic(topicObj) if 'user' in request.args: try: filterUser = User(g.db, int(request.args['user'])) except InvalidUserError, e: return not_found() postList.user(filterUser)
def api_user_posts(userid): """ Display a single user's posts. Requires authentication. Request params: topic, limit, start """ try: userObj = User(g.db, userid) except InvalidUserError: return not_found() postList = PostList(g.db) postList.db.where(('posts.userid=%s', userObj.id)) if 'topic' in request.args: try: filterTopic = Topic(g.db, int(request.args['topic'])) except InvalidUserError, e: return not_found() postList.topic(filterTopic)