def itemModel(category_id=None, user_id=None): try: items = None if (category_id is None and user_id is None): items = models.select_all_items() elif (category_id is not None and user_id is None): items = models.select_items_by_category(category_id) elif (category_id is None and user_id is not None): items = models.select_items_by_user_id(user_id) else: items = models.select_items_by_user_id_and_category_id( user_id, category_id) if items is None: abort(403) else: return utilities.status( utilities.convert_list_to_xml('items', [ utilities.convert_object_to_xml('item', r.serialize) for r in items ]), 200, 'xml') except: print "Unexpected error:", sys.exc_info()[0] print "Unexpected error:", sys.exc_info()[1] abort(403)
def categoryModel(): try: categories = models.load_categories() if categories is None: abort(403) else: return utilities.status(utilities.convert_list_to_xml('categories', [utilities.convert_object_to_xml('category', r.serialize) for r in categories]), 200, 'xml') except: print "Unexpected error:", sys.exc_info()[0] print "Unexpected error:", sys.exc_info()[1] abort(403)
def categoryModel(): try: categories = models.load_categories() if categories is None: abort(403) else: return utilities.status( utilities.convert_list_to_xml('categories', [ utilities.convert_object_to_xml('category', r.serialize) for r in categories ]), 200, 'xml') except: print "Unexpected error:", sys.exc_info()[0] print "Unexpected error:", sys.exc_info()[1] abort(403)
def imagesModel(category_id=None): try: images = None if (category_id is None): images = models.load_all_images() else: images = models.load_all_images_by_category(category_id) if images is None: abort(403) else: return utilities.status(utilities.convert_list_to_xml('images', [utilities.convert_object_to_xml('image', r.serialize) for r in images]), 200, 'xml') except: print "Unexpected error:", sys.exc_info()[0] print "Unexpected error:", sys.exc_info()[1] abort(403)
def imagesModel(category_id=None): try: images = None if (category_id is None): images = models.load_all_images() else: images = models.load_all_images_by_category(category_id) if images is None: abort(403) else: return utilities.status( utilities.convert_list_to_xml('images', [ utilities.convert_object_to_xml('image', r.serialize) for r in images ]), 200, 'xml') except: print "Unexpected error:", sys.exc_info()[0] print "Unexpected error:", sys.exc_info()[1] abort(403)
def itemModel(category_id=None, user_id=None): try: items = None if (category_id is None and user_id is None): items = models.select_all_items() elif (category_id is not None and user_id is None): items = models.select_items_by_category(category_id) elif (category_id is None and user_id is not None): items = models.select_items_by_user_id(user_id) else: items = models.select_items_by_user_id_and_category_id( user_id, category_id) if items is None: abort(403) else: return utilities.status(utilities.convert_list_to_xml('items', [utilities.convert_object_to_xml('item', r.serialize) for r in items]), 200, 'xml') except: print "Unexpected error:", sys.exc_info()[0] print "Unexpected error:", sys.exc_info()[1] abort(403)