auth.user is Storage(table_user._filter_fields(user, id=True)). The 
_filter_fields method of the auth_user table only selects actual table 
fields, not virtual fields, so auth.user will not include any virtual 
fields. Perhaps this should be changed.
 
Anthony

On Friday, July 29, 2011 9:05:39 PM UTC-4, Michael Toomim wrote:

> I think I found a bug in virtualfields. I have the following 
> controller: 
>
> def posts(): 
>     user = session.auth.user 
>     n = user.name # returns None 
>
> Where "person" is defined as a virtualfield on user: 
>
> class Users(): 
>     def name(self): 
>         return self.users.first_name + ' ' + self.users.last_name 
> db.users.virtualfields.append(Users()) 
>
> The problem is that user.name returns None, because apparently the 
> virtualfield isn't loaded into the session variable of user. 
>
> I made this work with the following modification to the controller: 
>
> def posts(): 
>     user = db.users[session.auth.user.id] 
>     n = user.name # returns the user name correctly! 
>
> I just had to refetch the user from the database.

Reply via email to