def searchResource(self, args): category = args.get("category") name = args.get("name") type = args.get("type") dao = ResourceDAO() resources_list = [] if (len(args) == 3) and category and name and type: resources_list = dao.getResourceByCategoryTypeAndName(category, type, name) elif (len(args) == 2) and category and name: resources_list = dao.getResourceByCategoryAndName(category, name) elif (len(args) == 2) and category and type: resources_list = dao.getResourceByCategoryAndType(category, type) elif (len(args) == 2) and type and name: resources_list = dao.getResourceByTypeAndName(type, name) elif (len(args) == 1) and category: resources_list = dao.getResourceByCategory(category) elif (len(args) == 1) and type: resources_list = dao.getResourceByType(type) elif (len(args) == 1) and name: resources_list = dao.getResourceByName(name) else: return jsonify(Error = "Malformed query string"), 400 if not resources_list: return jsonify(Error="Resource Not Found"), 404 else: result_list = [] for row in resources_list: result = self.build_resource_dict(row) result_list.append(result) return jsonify(Resources=result_list)
def searchResource(self, args): dao = ResourceDAO() name = args.get('RName') category = args.get('RCategory') if (len(args) == 1) and name: resource_list = dao.getResourceByName(name) elif (len(args) == 1) and category: resource_list = dao.getResourceByCategory(category) elif (len(args) == 2) and name and category: resource_list = dao.getResourceByNameAndCategory(name, category) else: return jsonify(Error="Malformed query string"), 400 if not resource_list: return jsonify(Error="Resource Not Found"), 404 result_list = [] for row in resource_list: result = self.build_resource_dict(row) result_list.append(result) return jsonify(Resource=result_list)