Denes,

Thanks for you reply. The function now reads like:

def byzipcode():
    form=form_factory(SQLField('zipcoderegion',requires=IS_NOT_EMPTY
()))
    if form.accepts(request.vars,session):
        minmax=db(db.zipcoderegions.region==request.vars.zipcoderegion)
\
        .select(db.zipcoderegions.codemin,db.zipcoderegions.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)


but still isn't working. The error ticket: minimum=int(minmax.codemin)
AttributeError: 'SQLRows' object has no attribute 'codemin'


I am trying to solve the problem using a test function. The following
code works:

def zipcoderegions():
    form=form_factory(SQLField('zipcoderegion'))
    if form.accepts(request.vars,session):
        region=request.vars.zipcoderegion
        minmax=db(db.zipcoderegions.region==request.vars.zipcoderegion)
\
.select(db.zipcoderegions.codemin,db.zipcoderegions.codemax)
        minimum='7300'
        maximum='7399'
    else:
        region='0'
        minmax=[]
        minimum='0'
        maximum='0'
    return dict
(form=form,minmax=minmax,minimum=minimum,maximum=maximum,region=region)


However, when I replace '7300' with minmax.codemin the error is
introduced:

File "/Library/Python/2.5/site-packages/web2pyfitwise/applications/
core/controllers/clublocator.py", line 58, in zipcoderegions
    minimum=minmax.codemin
AttributeError: 'SQLRows' object has no attribute 'codemin'

I hope this gives you sufficient information to help me solve the
problem.




> 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'


So even though I set the type to integer, when I get the value from
the interface I have to cast it to an integer, as in Java.


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
-~----------~----~----~----~------~----~------~--~---

Reply via email to