> 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.
Yes, but I had hoped that this function:
@auth.requires_login()
def index():
if auth.user.account!='1':
redirect(URL(r=request,c='view',f='index'))
else:
response.functionname='Business Card'
return dict()
.. and this view:
{{if 'promobox' in globals():}}
<div class="sidebox">
{{if promobox[0].kop:}}
<h3>{{=promobox[0].kop}}</h3>
{{pass}}
{{=XML(promobox[0].tekst)}}
</div> <!-- sidebox -->
{{pass}}
.. would, in case of re-using views, prevent me from returning empty
lists to the view for every variable in the view I do not assign a
value to in the function.
I solved the problem using the last function, but I was curious why
the function and view in the first post result in: TypeError:
'function' object is unsubscriptable.
Kind regards,
Annet.