The deform select widget takes a sequence of two element tuples. How do I create two element tuples from two columns from an sqlalchemy query.
The below code works with the 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, but found the solution to be more straight forward than I 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)
)