I have a 2 part question I am rather new to web2py, I am trying to
merely generate several drop down forms of the unique values for a
field. I have accomplished this but feel there is a better way to do
so, if you see a better way feel free to comment. Second I want to
take these values and perform a db search returning the db rows/values
that match such query, but I can't seem to get the session vars to
work correctly. Or is there an alternate method that would work
better? In the example below I am merely trying to display the
values I am getting from the drop down but it does not seem to work.
##model
db.define_table('aa', Field('name'),
Field( 'color','string',label ='color'),
Field('weight','integer')
)
##controller
def index():
bla = session.vars
return dict(message=T('Hello World'),var = bla)
def formtry():##this works, I could not get the IS_IN_DB version to
display the fields correctly so i used the SET version
from sets import Set
ra = db().select(db.aa.color, distinct=True)
SA = Set()
for row in ra:
SA.add(row.color)
##ra = db().select(db.aa.color, distinct=True)
##form = SQLFORM.factory(SQLField('color', label='Select a
service'), requires=IS_IN_DB(db,'aa.color'))
form = SQLFORM.factory(
Field('color', requires=IS_IN_SET(SA)))
if form.accepts(request.vars, session):
response.flash = 'form accepted'
redirect(URL('index',vars ={'bla' :request.vars}))##I want to
take this variable and perform a search and return the values on
another page for instance index, does anyone see a way to do that?
I've tried a few different formats
return dict(form = form,vabla = session.vars)