Yep. What Duvo said. Or using DeMorgan's theorem you could say:
if not (club and address and nfas) http://en.wikipedia.org/wiki/De_Morgan%27s_laws On Jun 30, 8:40 am, annet <[email protected]> wrote: > I have a master-detail use case, the details function reads like: > > def details(): > id=request.args[0] > club=db(db.bedrijf.id==id).select > (db.bedrijf.bedrijfsnaam,db.bedrijf.kvk_nummer,\ > db.bedrijf.subdossiernummer,db.bedrijf.status) > 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==1)).select(db.adres.ALL) > 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 or address or nfas): redirect(URL > (r=request,f='byplace')) > return dict(club=club[0],address=address[0],nfas=nfas) > > This works, however, when the visitor manipulates the id in the > browser an error ticket is issued: > > Traceback (most recent call last): > File "/Library/Python/2.5/site-packages/web2py_1_64_4/gluon/ > restricted.py", line 107, in restricted > exec ccode in environment > File "/Library/Python/2.5/site-packages/web2py_1_64_4/applications/ > core/controllers/clublocator.py", line 70, in <module> > File "/Library/Python/2.5/site-packages/web2py_1_64_4/gluon/ > globals.py", line 100, in <lambda> > self._caller = lambda f: f() > File "/Library/Python/2.5/site-packages/web2py_1_64_4/applications/ > core/controllers/clublocator.py", line 56, in details > id=request.args[0] > IndexError: list index out of range > > Rewriting the function to read like: > > def details(): > id=request.args[0] > club=db(db.bedrijf.id==id).select > (db.bedrijf.bedrijfsnaam,db.bedrijf.kvk_nummer,\ > db.bedrijf.subdossiernummer,db.bedrijf.status) > if not club: > redirect(URL(r=request,c='default',f='index')) > elif club[0].status=='0': > redirect(URL(a='site',c='default',f='index',args=id)) > else: > address=db((db.adres.bedrijf==id)& > (db.adres.adressoort==1)).select(db.adres.ALL) > 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 or address or nfas): redirect(URL > (r=request,c='default',f='index')) > return dict(club=club[0],address=address[0],nfas=nfas) > > i.e. adding: > > if not club: > redirect(URL(r=request,c='default',f='index')) > > ... solves the problem, but leaves me puzzled as to why this: > > if not (club or address or nfas): redirect(URL > (r=request,c='default',f='index')) > > ... doesn't prevent the ticket from being issued. > > Kind 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

