Actually I did notice that typo, I tried the append() already, my code
is:

  class VirtualFields:
    def profit(self): return self.Orders.income - self.Orders.cost
  db.Orders.virtualfields.append(VirtualFields())

this line runs fine, but later when I need to access a virtual field,
an exception is raised:

  File "C:\DOWNLOAD\google_appengine\web2py\gluon\sql.py", line 658,
in __getitem__
    return dict.__getitem__(self, key)
KeyError: 'profit'

Ideas? Thanks.

-Iceberg

On Apr5, 12:00pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> I think its
>
> db.table.virtualfields.append()
>
> -Thadeus
>
>
>
> On Sun, Apr 4, 2010 at 10:51 PM, Iceberg <iceb...@21cn.com> wrote:
> > Hi there,
>
> > I search virtualfields inhttp://www.web2py.com/bookbut found
> > nothing.
>
> > So I read this post instead:  
> > https://groups.google.com/group/web2py/browse_frm/thread/d59ee3d6c2e6...
>
> > But I found that
> >  db.table.virtualfields.add(ComputedFields())
> > doesn't work.
>
> > Only this work:
> >  rows.setvirtualfields(table=ComputedFields())
>
> > Does the former syntax really supposed to exist?
>
> > I am using web2py 1.75.4
>
> > Regards,
> > Iceberg
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > web2py+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/web2py?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to