i face the same situation before, but because i use bulk_insert in
controller install.py so that i put the conditional if on it.
e.g.
*models/db.py*
# after_insert_purchase_detail
def __after_insert_purchase_detail(f, id):
db(db.dvd.id == f.dvd).update(quantity = db.dvd(f.dvd).quantity +
f.quantity)
# on_define_purchase_detail
def on_define_purchase_detail(table):
# callbacks
if not 'install' in request.controller :
# _after_insert
table._after_insert.append(__after_insert_purchase_detail)
# create table : purchase_detail
db.define_table('purchase_detail',
Field('purchase_no', 'reference purchase_header'),
Field('dvd', 'reference dvd'),
Field('quantity', 'integer'),
Field('price', 'integer'),
on_define = on_define_purchase_detail,
format = '%(purchase_no)s')
*controllers/install.py*
# purchase_detail
db.purchase_detail.bulk_insert([{"purchase_no" : 1, "dvd" : 1, "quantity" :
1,
"price" : 15000},
{"purchase_no" : 2, "dvd" : 3, "quantity" : 1,
"price" : 15000},
{"purchase_no" : 2, "dvd" : 4, "quantity" : 1,
"price" : 15000}, ])
hopefully, after the bug is fixed i don't have to put the conditional if to
check the controller again.
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.