Are you showing your exact code, because the particular error reported will
only appear if the computed field is required, and you have not set the
total_square_meter field to be required?
Anthony
On Saturday, January 23, 2016 at 9:31:18 PM UTC-5, 黄祥 wrote:
>
> still face the same error :
> e.g.
> db.define_table('default_size',
> Field('name'),
> Field('length_in_cm', 'double'),
> Field('width_in_cm', 'double'),
> Field('total_square_meter', 'double'),
> Field('acquisition_price', 'integer') )
>
> db.default_size.total_square_meter.compute = lambda r:
> (float(r['length_in_cm'] ) * float(r['width_in_cm'] ) ) / 10000
>
> def __after_insert_purchase_order_detail(f, id):
> db(db.default_size.id == f.default_size).update(acquisition_price =
> f.price)
>
>
> db.purchase_order_detail._after_insert.append(__after_insert_purchase_order_detail)
>
> Traceback (most recent call last):
> File "/Users/MacBookPro/site/web2py/gluon/restricted.py", line 227, in
> restricted
> exec ccode in environment
> File
> "/Users/MacBookPro/site/web2py/applications/glassworkshop/controllers/transaction.py"
>
> <http://127.0.0.1:8000/admin/default/edit/glassworkshop/controllers/transaction.py>,
> line 246, in <module>
> File "/Users/MacBookPro/site/web2py/gluon/globals.py", line 412, in <lambda>
> self._caller = lambda f: f()
> File
> "/Users/MacBookPro/site/web2py/applications/glassworkshop/controllers/transaction.py"
>
> <http://127.0.0.1:8000/admin/default/edit/glassworkshop/controllers/transaction.py>,
> line 174, in purchase_order_header
> price = price)
> File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py",
> line 734, in insert
> [f(fields, ret) for f in self._after_insert]
> File
> "/Users/MacBookPro/site/web2py/applications/glassworkshop/models/db_wizard_4_purchase_order.py"
>
> <http://127.0.0.1:8000/admin/default/edit/glassworkshop/models/db_wizard_4_purchase_order.py>,
> line 66, in __after_insert_purchase_order_detail
> db(db.default_size.id == f.default_size).update(acquisition_price =
> f.price)
> File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py",
> line 2056, in update
> fields = table._listify(update_fields,update=True)
> File "/Users/MacBookPro/site/web2py/gluon/packages/dal/pydal/objects.py",
> line 686, in _listify
> raise SyntaxError('unable to compute field: %s' % name)
> SyntaxError: unable to compute field: total_square_meter
>
>
> is there any way to face this?
>
> thanks and best regards,
> stifan
>
--
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.