Example #1
0
def get_all_users():
    """ FOr search functionality"""

    q = db_session.query(User)
    rs = q.all()
    out_l = []
    c = 0
    for row in rs:
        out_l.append(row)
        c += 1
        if c >= 25: break
    # ..todo:: the worst limiting case ever... 
    return out_l
Example #2
0
def get_user_by_identifier(unquoted_id):
    """ """

    ### Now lets recreate it.

    q = db_session.query(Identifier)
    q = q.filter(Identifier.identifierstring == unquoted_id)
    rs = q.all()

    if len(rs) == 0:
        raise Rhaptos2Error("Identifer ID Not found in this repo")
    if len(rs) > 1:
        raise Rhaptos2Error("Too many matches")

    #.. todo:: stop using indexes on rows - transform to fieldnames
    user_id = rs[0].user_id
    newu = get_user(user_id)
    return newu 
Example #3
0
def get_user(user_id):
    """
    returns a User object, when provided with user_id 
    """

    ### Now lets recreate it.

    q = db_session.query(User)
    q = q.filter(User.user_id == user_id)
    rs = q.all()
    if len(rs) == 0:
        raise Rhaptos2Error("User ID Not found in this repo")
    ### There is a uniq constraint on the table, but anyway...
    if len(rs) > 1:
        raise Rhaptos2Error("Too many matches")
    
    newu = rs[0]
    return newu
Example #4
0
def get_user_by_name(namefrag):
    """
    Perform a case insensitive search on fullname

    I would like to offer at least two other searches, 
    specifying the fields to search, and a frag search across 
    many fields.
    """

    q = db_session.query(User)
    q = q.filter(or_(
                     User.fullname.ilike("%%%s%%" % namefrag),
                     User.email.ilike("%%%s%%" % namefrag),
                     ))
    rs = q.all()
    out_l = []
    for row in rs:
        out_l.append(row)
    return out_l