I think what is happening is the model is exec'd at the start of the
request but if the user is not logged in yet or the session has
expired forcing a trip to the login page, the model with get None
because auth is not in the session. Once the trip to the login page
completes it goes back to the controller that was initially started
but I am not sure it re-evaluates the model. Putting the code in the
controller pushes in a value after login has completed.

On Oct 24, 11:53 pm, annet <annet.verm...@gmail.com> wrote:
> As far as I know auth.user.id should work. However, I faced a similar
> problem and solved it by setting the default in the function,
> something like:
>
> def add_comment():
>     ....
>     db.comment.user.default=auth.user.id
>     ....
>     return dict(...)
>
> Maybe someone else can provide you (and me) with an explanation.
>
> Kind regards,
>
> Annet

Reply via email to