Maybe it helps for me to explain my use-case. I mainly use virtual fields as lazy methods, to help traverse related tables. I was actually surprised that lazy evaluation wasn't the default. I noticed a few implications of this: - Large queries are slowed by virtualfields, even if they won't be needed, esp if they query db - My definitions for virtualfields aren't as clean as they could be, because I have many nested "lazy" funcs in the class definition - We can't serialize all objects into session variables
So really I'm just using this because it's a nicer notation to call row.otherthing() instead of getotherthing(row). Maybe I really want some different feature here? On Aug 1, 2011, at 5:40 AM, Anthony Bastardi wrote: > Note, after looking at this some more, Massimo recalled that the reason > auth_user virtual fields were excluded from auth.user (and therefore from > saving in the session) is because some virtual fields are objects that cannot > be pickled and therefore cannot be serialized to store in the session. So, > we're thinking of either creating an option to store auth_user virutual > fields in auth.user, or maybe testing to make sure the virtual fields can be > pickled, and excluding them if not. > > Anthony > > On Mon, Aug 1, 2011 at 5:30 AM, Michael Toomim <too...@cs.washington.edu> > wrote: > Awesome! I did not know there was an issue submission system. > > On Jul 30, 2011, at 7:02 AM, Anthony wrote: > >> An issue has been submitted, and this should be corrected soon. >> >> Anthony >> >> On Friday, July 29, 2011 9:57:30 PM UTC-4, Anthony wrote: >> 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. > >