The extra space before "if t:" must have caused the syntax error.Sorry,my
bad.The code with the correct syntax is as follows:
#################models/db1.py

db.define_table('Restaurant',
                Field('Name',unique=True),
..................................................
.......................auth.signature,format='%(Name)s')

db.define_table('Menu',
                Field('menu','upload'),
                Field('restaurant','reference Restaurant',writable=False))



###########controller/func()
indices=db(db.Menu).select()
for index in indices:
    t=db(index.restaurant.Name==request.args[0]).select(db.Menu.ALL).first()
    if t:
        record=db.Menu(t.id)
        form=SQLFORM(db.Menu,record).process()
......................................................................
.....................................................................


Regards,
Brooks

On Fri, Sep 2, 2016 at 12:54 AM, Dave S <snidely....@gmail.com> wrote:

>
>
> On Thursday, September 1, 2016 at 11:47:55 AM UTC-7, @brooks wrote:
>>
>> So my question goes as follows:
>> #################models/db1.py
>>
>> db.define_table('Restaurant',
>>                 Field('Name',unique=True),
>> ..................................................
>> .......................auth.signature,format='%(Name)s')
>>
>> db.define_table('Menu',
>>                 Field('menu','upload'),
>>                 Field('restaurant','reference Restaurant',writable=False))
>>
>>
>> ############controller/func()
>> indices=db(db.Menu).select()
>> for index in indices:
>>     t=db(index.restaurant.Name==request.args[0]).select(db.Menu.
>> ALL).first()
>>             if t:
>>                 record=db.Menu(t.id)
>>                 form=SQLFORM(db.Menu,record).process()
>> ......................................................................
>> .....................................................................
>>
>> (I have one record in the Menu table now)
>> The question is that the first record gets selected even if the condition
>> is not true.I do not understand it.Please tell me what I am doing wrong.Any
>> help is appreciated.
>>
>> Regards,
>> Brooks
>>
>
> I dunno, but I get a syntax error trying to translate your for ... select
> into something I can try with -S and my tables.  Is db(<ROW object>)
> meaningful?
>
> /dps
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/E4VyjG0jS94/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to