

def create_pick_list(node, modelclass, filtermap=None):
    vlist = []
    q = dbsession.query(modelclass)
    try:
        order_by = modelclass.ROW_DISPLAY[0]
        q = q.order_by(getattr(modelclass, order_by))
    except (AttributeError, IndexError):
        pass
    if filtermap:
        for (name, value) in filtermap.items():
            attrib = getattr(modelclass, name)
            q = q.filter((attrib == value))
    for dbrow in q:
        vlist.append((dbrow.id, str(dbrow), False))
    name = modelclass.__name__
    elid = ('id_' + name)
    node.add_label(name, elid)
    return node.add_select(vlist, name=name.lower(), multiple=False, id=elid)

dataset/ETHPy150Open kdart/pycopia/storage/pycopia/db/webhelpers.py create_pick_list/original