

def new_relation_input(node, modelclass, metadata, order_by=None):
    choices = models.get_choices(dbsession, modelclass, metadata.colname, order_by)
    if (not choices):
        return node.new_para(('%s has no choices.' % metadata.colname))
    if metadata.nullable:
        choices.insert(0, (0, '----'))
    elid = ('id_' + metadata.colname)
    node.add_label(metadata.colname, elid)
    return node.add_select(choices, name=metadata.colname, multiple=metadata.uselist, id=elid)

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