def post_list(): connection = db_tools.connect() content = functions.get_json(request) try: identifier = content["forum"] entity = "forum" except KeyError: try: identifier = content["thread"] entity = "thread" except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) optional = functions.get_optional(request=content, values=["limit", "order", "since"]) try: p_list = post_tools.posts_list(connection=connection, entity=entity, params=optional, identifier=identifier, related=[]) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": p_list})
def list_users(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional(params, ["since_id", "limit", "order"]) try: functions.check(params, ["forum"]) response = forum_tools.list_users( connection=connection, optional=optional, short_name=params["forum"][0]) except Exception, e: return json.dumps({"code": 3, "response": (e.message)})
def list_threads(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional(params, ["since", "limit", "order"]) related = functions.get_related(params) try: functions.check(params, ["forum"]) response = thread_tools.list(connection=connection, optional=optional, required=params, related=related) except Exception, e: return json.dumps({"code": 3, "response": (e.message)})
def details(): connection = db_tools.connect() params = functions.get_json(request) try: functions.check(params, ["forum"]) response = forum_tools.details( connection, params["forum"], functions.get_related(params)) except Exception, e: return json.dumps({"code": 3, "response": (e.message)})
def list_users(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional(params, ["since_id", "limit", "order"]) try: functions.check(params, ["forum"]) response = forum_tools.list_users(connection=connection, optional=optional, short_name=params["forum"][0]) except Exception, e: return json.dumps({"code": 3, "response": (e.message)})
def details(): connection = db_tools.connect() params = functions.get_json(request) try: functions.check(params, ["forum"]) response = forum_tools.details(connection, params["forum"], functions.get_related(params)) except Exception, e: return json.dumps({"code": 3, "response": (e.message)})
def post_details(): connection = db_tools.connect() params = functions.get_json(request) required_data = ["post"] related = functions.get_related(params) try: functions.check(params, required_data) response = post_tools.details(connection, params["post"], related) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": response})
def details(): connection = db_tools.connect() params = functions.get_json(request) try: functions.check(params, ["user"]) userr = user_tools.details(connection, params["user"][0]) except Exception as e: connection.close() return jsonify({"code": 1, "response": e.message}) connection.close() return jsonify({"code": 0, "response": userr})
def list_posts(): connection = db_tools.connect() params = functions.get_json(request) entity = "thread" optional = functions.get_optional( request=params, values=["limit", "order", "since", "sort"]) try: functions.check(params, ["thread"]) response = post_tools.posts_list( connection=connection, entity="thread", params=optional, identifier=params["thread"], related=[]) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": response})
def list_posts(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional(params, ["since", "limit", "order", "sort"]) related = functions.get_related(params) try: functions.check(params, ["forum"]) response = post_tools.posts_list(connection, entity="forum", params=optional, identifier=params["forum"], related=related) except Exception, e: return json.dumps({"code": 3, "response": (e.message)})
def list_followees(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional(params, ["limit", "order", "since_id"]) try: functions.check(params, ["user"]) response = user_tools.list_followees(connection, params["user"], optional) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": response})
def list_posts(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional( params, ["since", "limit", "order", "sort"] ) related = functions.get_related(params) try: functions.check(params, ["forum"]) response = post_tools.posts_list(connection, entity="forum", params=optional, identifier=params[ "forum"], related=related) except Exception, e: return json.dumps({"code": 3, "response": (e.message)})
def details_thread(): connection = db_tools.connect() params = functions.get_json(request) required_data = ["thread"] related = functions.get_related(params) if 'thread' in related: connection.close() return json.dumps({"code": 3, "response": "error"}) try: functions.check(params, required_data) response = thread_tools.details(connection, params["thread"], related) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": response})
def list_posts(): connection = db_tools.connect() params = functions.get_json(request) entity = "thread" optional = functions.get_optional( request=params, values=["limit", "order", "since", "sort"]) try: functions.check(params, ["thread"]) response = post_tools.posts_list(connection=connection, entity="thread", params=optional, identifier=params["thread"], related=[]) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": response})
def list_thread(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional( request=params, values=["since", "limit", "order"]) try: response = thread_tools.list(connection=connection, required=params, optional=optional, related=[]) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": response})
def list_thread(): connection = db_tools.connect() params = functions.get_json(request) optional = functions.get_optional(request=params, values=["since", "limit", "order"]) try: response = thread_tools.list(connection=connection, required=params, optional=optional, related=[]) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": response})
def post_list(): connection = db_tools.connect() content = functions.get_json(request) try: identifier = content["forum"] entity = "forum" except KeyError: try: identifier = content["thread"] entity = "thread" except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) optional = functions.get_optional( request=content, values=["limit", "order", "since"]) try: p_list = post_tools.posts_list( connection=connection, entity=entity, params=optional, identifier=identifier, related=[]) except Exception as e: connection.close() return json.dumps({"code": 1, "response": (e.message)}) connection.close() return json.dumps({"code": 0, "response": p_list})