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)
Exemple #2
0
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:
            feed = utilities.create_feed('items', request)
            for item in items:
                feed.add(item.id,
                         item.category_id,
                         id=item.id,
                         content_type='html',
                         updated=item.created_at,
                         published=item.updated_at or item.created_at,
                         user_id=item.user_id,
                         category_id=item.category_id,
                         image_id=item.image_id)
            return feed.get_response()
    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:
            feed = utilities.create_feed('items', request);
            for item in items:
                feed.add(
                    item.id,
                    item.category_id,
                    id=item.id,
                    content_type='html',
                    updated=item.created_at,
                    published=item.updated_at or item.created_at,
                    user_id=item.user_id,
                    category_id=item.category_id,
                    image_id=item.image_id)
            return feed.get_response()
    except:
        print "Unexpected error:", sys.exc_info()[0]
        print "Unexpected error:", sys.exc_info()[1]
        abort(403)
Exemple #4
0
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 jsonify(items=[r.serialize for r in items])
    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 jsonify(items=[r.serialize for r in items])
    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)