Don't take this as a sure thing, but a big improvement was made on 
1.99.4/1.99.7 to avoid the behaviour that all decorators (as @auth.requires 
is) were executed no matter what function you were requesting for that 
controller. Don't know if that fix brought to your situation.
I think your situation can be easily fixed though: before you had a 
default=None for that field, so just set a variable before the table 
definition as

tenant_field = session.auth.user.request_tenant if session.auth.user or None

and use tenant_field instead of session.auth.user.request_tenant for the 
default value of the field.

On Monday, October 22, 2012 10:10:16 PM UTC+2, Cliff Kachinske wrote:
>
> My models reference session.auth.user as follows:
>
> Field('request_tenant', default=session.auth.user.request_tenant)
>
> Obviously this will fail if the user is not logged in because 
> session.auth.user is None.
>
> In 1.99.2, using any of the @auth decorators forces a login before the 
> model files run, so there is no problem.
>
> In 2.1.1, errors occur.  It seems like the models are being run before the 
> decorators have been evaluated, whereas in 1.99.2 the decorators were 
> evaluated first.
>
> Has something changed in Web2py?
>
> The applicable model files are identical, according to diff. The 
> controllers are not, but I made no changes to the index functions and I get 
> the error when running index.
>
> Any idea what's going on?
>

-- 



Reply via email to