In the default controller I adjusted the user() function:
def user():
"""
exposes:
...
"""
form=auth()
form[0][-1]
[1].append(INPUT(_type="button",_value="Cancel",_onclick="window.location='%s';"%URL(r=request,f='index')))
return dict(form=form)
This works well, until a user requests access to a function he doesn't
have access to. Web2py then redirects to:
http://127.0.0.1:8000/cms/default/user/not_authorized
... which results in the following error;
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/controllers/default.py", line 118, in <module>
File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
globals.py", line 96, in <lambda>
self._caller = lambda f: f()
File "/Library/Python/2.5/site-packages/web2py_1.87.3/applications/
cms/controllers/default.py", line 25, in user
form[0][-1]
[1].append(INPUT(_type="button",_value="Cancel",_onclick="window.location='%s';"%URL(r=request,f='index')))
IndexError: string index out of range
This is how I fixed the problem, not very elegant, and probably
overlooking other conditions:
def user():
"""
exposes:
...
"""
form=auth()
if not request.args(0)=='not_authorized':
form[0][-1]
[1].append(INPUT(_type="button",_value="Cancel",_onclick="window.location='%s';"%URL(r=request,f='index')))
return dict(form=form)
I wonder whether there is a better way to solve this problem.
Kind regards,
Annet