On Oct 16, 9:03 am, annet <[email protected]> wrote:
>
> I also tried:
>
> @auth.requires_login()
> def index():
> if auth.user.account!='1':
> redirect(URL(r=request,c='view',f='index'))
> else:
> response.functionname='Business Card'
> box=[]
> return dict(promobox=box)
>
> .. but that resulted in:
>
> Traceback (most recent call last):
> File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> restricted.py", line 188, in restricted
> exec ccode in environment
> File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/
> cms/views/card/index.html", line 137, in <module>
> IndexError: list index out of range
This error makes sense, promobox is an empty list and
any attempt to index it (as in promobox[0]) will give the error.
Note that is different from the error in your first post.
> Given the last function, this view works:
>
> {{if promobox:}}
> <div class="sidebox">
> {{if promobox[0].kop:}}
> <h3>{{=promobox[0].kop}}</h3>
> {{pass}}
> {{=XML(promobox[0].tekst)}}
> </div> <!-- sidebox -->
> {{pass}}
>
> .. so {{if promobox:}} instead of {{if 'promobox'in globals():}}
>
> I hope I provided you with sufficient information to find out why the
> errors occur.
>
> Kind regards,
>
> Annet.