예제 #1
0
파일: helpers.py 프로젝트: serg9008/walkr
def get_user(username):
    """
    Returns the User object from the model.

    :rtype: :class:`inphosite.model.User`
    """
    user = Session.query(User).filter_by(username=username.lower()).first()
    return user
예제 #2
0
def get_user(username):
    """
    Returns the User object from the model.

    :rtype: :class:`inphosite.model.User`
    """
    user = Session.query(User).filter_by(username=username.lower()).first()
    return user
예제 #3
0
파일: helpers.py 프로젝트: serg9008/walkr
def fetch_obj(type, id, error=404, new_id=False):
    """
    Fetches the object with the given id from the collection of type type. If
    the object does not exist, throw an HTTP error (default: 404 Not Found).

    :param type: object type
    :type type: class in :mod:`inphosite.model`
    :param id: object id
    :type id: integer or None
    :param error: HTTP error code.
    :rtype: *type*
    """
    if id is None:
        abort(error)
    obj_q = Session.query(type)
    obj = obj_q.get(int(id))
    #else:
    #    obj = obj_q.filter(type.ID==int(id)).first()

    if obj is None:
        abort(error)
    return obj
예제 #4
0
def fetch_obj(type, id, error=404, new_id=False):
    """
    Fetches the object with the given id from the collection of type type. If
    the object does not exist, throw an HTTP error (default: 404 Not Found).

    :param type: object type
    :type type: class in :mod:`inphosite.model`
    :param id: object id
    :type id: integer or None
    :param error: HTTP error code.
    :rtype: *type*
    """
    if id is None:
        abort(error)
    obj_q = Session.query(type)
    obj = obj_q.get(int(id))
    #else:
    #    obj = obj_q.filter(type.ID==int(id)).first()

    if obj is None:
        abort(error)
    return obj