Do you have an "id" field defined?

Richard

On Sat, Aug 6, 2016 at 6:31 AM, Vic Ding <[email protected]> wrote:

> I created the table initially without the virtual field 'amount' and added
> it lately.
> When I use a string or number in the lambda like: lambda row: 'test', it
> works fine.
> However, when I use lambda row: row.id it gave the error below. It's
> really like push here and feel the pain 2km away.
> Someone get some idea? Thanks!
>
> my db:
>
> db.define_table('inoutexp',
>                 auth.signature,
>
>
>                 Field('qty', 'integer', requires=IS_NOT_EMPTY()),
>                 Field.Virtual('amount', lambda row: row.qty, 
> label=T('Amount'))
>
>                 )
>
>
> simply a grid:
>
> grid = SQLFORM.grid(db.inoutexp)
>
>
> The error:
>
> Function argument list
>
> (self=<Row { 'qty': 5, '...ime.datetime(2016, 8, 3, 14, 9, 46)}>,
> k='inoutexp.amount')
> Code listing
>
> 71.
> 72.
> 73.
> 74.
> 75.
> 76.
>
> 77.
> 78.
> 79.
> 80.
>
>                 self[key] = e(key)
>                 return self[key]
>         except Exception as e:
>             raise e
>
>         raise KeyError
>
>
>     __str__ = __repr__ = lambda self: '<Row %s>' % 
> self.as_dict(custom_types=[LazySet])
>
>     __int__ = lambda self: self.get('id')
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to