python - How to create tuples from two columns with sqlalchemy, populate deform select widget from database -


the deform select widget takes sequence of 2 element tuples. how create 2 element tuples 2 columns sqlalchemy query.

the below code works hardcoded example.

class profilevalueselect(colander.mappingschema):     choices = (         ('', '- select -'),         ('one', 'one'),         ('two', 'two'),         ('three', 'three')     )     menu = colander.schemanode(         colander.string(),         title=false,         missing=unicode(''),         widget=deform.widget.selectwidget(values=choices)     ) 

didn't supply enough information, found solution more straight forward thought.

class profilevalueselect(colander.mappingschema):     result = dbsession.query(profile.uid, profile.value).order_by(profile.value).all()     menu = colander.schemanode(     colander.string(),     title=false,     missing=unicode(''),     widget=deform.widget.selectwidget(values=result) ) 


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -