Regarding your code...
if request.args(0) == 'login':
return dict(form=form,layout='login_layout.html')
else:
return dict(form=form,layout='layout.html')
if request.args[0] == 'profile':
return dict(form='you are not allowed
(permission)',layout='layout.html')
... I suppose it never arrives at the 'profile' line??
Maybe it should be something like ...
if request.args(0) == 'login':
return dict(form=form,layout='login_layout.html')
elif request.args[0] == 'profile':
return dict(form='you are not allowed
(permission)',layout='layout.html')
else:
return dict(form=form,layout='layout.html')
Just a guess.
Best wishes,
-D