Just to add to Yarko's reply, the tablename.fieldname syntax to access
row members (as in club[0].bedrijf.status) is required when the rows
come from joined tables.
If the rows come from a single table then only the fieldname is used.

The reason being that the resulting rows object is of type SQLStorage
(similar to a dictionary), that in the case of a single table query
has the field names as keys but when there are joins involved the rows
object becomes a multi-level SQLStorage with table names as primary
keys and field names as secondary keys.

Denes.

On Apr 21, 2:24 am, Yarko Tymciurak <yark...@gmail.com> wrote:
> Hi Annet -
> Try something like this:
>
> On Mon, Apr 20, 2009 at 1:37 AM, annet <jmverm...@xs4all.nl> wrote:
>
> > In the following function, the idea is to select a club's data based
> > on the id in request.args. Then if the club's status is 0 (the field
> > is of type string) the function should redirect to an other
> > application, else the address and nfa data should be selected from the
> > database and returned to the details view.
>
> > def details():
> >    id=request.args[0]
> >    club=db(db.bedrijf.id==id).select(db.bedrijf.ALL)
> >    if club[0].bedrijf.status=='0':
>
> This looks wrong;  since club[0] is a row from db.bedrijf, it should read
> like this:
>
>      if club[0].status == '0':
>
>
>
> >        redirect(URL(a='site',c='default',f='index',args=id))
> >    else:
> >        address=db((db.adres.bedrijf==id)&
> > (db.adres.adressoort=='Vestigingsadres')).select()
> >        nfas=db((db.bedrijfnfa.bedrijf==id)&
> > (db.bedrijfnfa.nfatype==db.nfatype.id))\
> >        .select
>
> > (db.bedrijfnfa.nfatype,db.bedrijfnfa.adres,db.nfatype.nfatype,orderby=db.bedrijfnfa.nfatype)
> >    if not club and address and nfas: redirect(URL
> > (r=request,f='byplace'))
> >    return dict(club=club[0],address=address[0],nfas=nfas)
>
> > This function is not working, the error references the if statement, I
> > have been tinkering with it, but then, even though the status of a
> > club is not 0 the function redirects.
>
> > What am I doing wrong?
>
> > Best regards,
>
> > 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