On Apr 8, 10:13 am, jmverm...@xs4all.nl wrote: > Given this model: > > db.define_table('zipcoderegions', > SQLField('region', type=integer, default='',notnull=True), > SQLField('codemin', type=integer, default='', notnull=True), > SQLField('codemax', type=integer,, default='', notnull=True), > migrate=False) >
SQLField type definitions are strings: type='integer' > and the values in the zipcoderegions table are: > > 73 7300 7399 > 80 8000 8099 > 91 9100 9199 > > I coded the following function: > def byzipcode(): > form=form_factory(SQLField('zipcoderegion',requires=IS_NOT_EMPTY > (), \ > widget=lambda self, value:TAG[''](INPUT > (_id='byzipcode',_name='zipcoderegion',_class='ac_input',_type='text')))) > if form.accepts(request.vars,session): > minmax=db(db.zipcoderegions.region==int > (request.vars.zipcoderegion)\ (request.vars.zipcoderegion))\ > .select(db.zipcoderegions.codemin,db.zipcoderegions.codemax) > minimum=(int)minmax.codemin > maximum=(int)minmax.codemax minimum=int(minmax.codemin) maximum=int(minmax.codemax) > clubs=db().select() ## the code in here works with fixed > arguments (7300 and 7399) > elif form.errors: > response.flash='form has errors' > else: > response.flash='please fill the form' > clubs=[] > return dict(form=form,clubs=clubs) > > So, if in the form a user types region: 73 minimum should become 7300 > and maximum 7399. This part of the code doesn't do the trick: > > minmax=db(db.zipcoderegions.region==int(request.vars.zipcoderegion)\ > .select(db.zipcoderegions.codemin,db.zipcoderegions.codemax) > minimum=(int)minmax.codemin > maximum=(int)minmax.codemax > > and I have no idea why not. > > Annet. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---