def not_implemented(e): status_code = 501 response = jsonify({ 'status': status_code, 'message': 'Not Implemented Yet' }) response.status_code = status_code app_log.error(repr(response), extra={'sender': 'DataSource'}) return response
def general_err(e): status_code = 500 response = jsonify({ "status": status_code, "message": ("{0}: {1}").format( type(e).__name__, repr(e)) }) response.status_code = status_code app_log.error(repr(response), extra={'sender': 'DataSource'}) return response
def get_labels(): """ Get label list :return: Object """ try: result = Label.query.all() return result except Exception as e: app_log.error(repr(e), extra={'sender': 'DataSource'}) raise e
def get_categories(): """ Get categories list :return: Object """ try: result = Categories.query.all() return result except Exception as e: app_log.error(repr(e), extra={'sender': 'DataSource'}) raise e
def set_category(name, desc=None): """ Add a categories :param obj:{name:"",desc:""} :return:True/False """ try: ca = Categories(name, desc) db.session.add(ca) db.session.commit() except Exception as e: db.session.rollback() app_log.error(repr(e), extra={'sender': 'DataSource'}) raise e
def handle_custom_err(error): response = jsonify(error.to_dict()) response.status_code = error.status_code app_log.error(repr(response), extra={'sender': 'DataSource'}) return response