[web2py] Re: _before_insert / update question

2015-06-01 Thread Ian Ryder
Done - thanks for your help On Friday, May 29, 2015 at 11:48:38 PM UTC+2, Anthony wrote: > > Yes, this is a bug in bulk_insert -- it calls the _listify method *before* > running the _before_insert callbacks instead of after (_listify changes the > format from a dictionary to a list of (field, va

[web2py] Re: _before_insert / update question

2015-05-29 Thread 黄祥
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.quanti

[web2py] Re: _before_insert / update question

2015-05-29 Thread Anthony
Yes, this is a bug in bulk_insert -- it calls the _listify method *before* running the _before_insert callbacks instead of after (_listify changes the format from a dictionary to a list of (field, value) tuples). If you don't mind, please file a pydal github issue and reference this post. Antho

[web2py] Re: _before_insert / update question

2015-05-29 Thread Ian Ryder
It was this: new_ilis = [] ... new_ili = { 'income': this_rg.template_income, 'income_coding': rgli.income_coding, 'amount_item': rgli.amount_item, 'quantity': rgli.quantity, 'income_source': rgli.income_source,

[web2py] Re: _before_insert / update question

2015-05-29 Thread Ian Ryder
It was this: new_ilis = [] ... new_ili = { 'income': this_rg.template_income, 'income_coding': rgli.income_coding, 'amount_item': rgli.amount_item, 'quantity': rgli.quantity, 'income_source': rgli.income_source,

[web2py] Re: _before_insert / update question

2015-05-29 Thread Anthony
Possible bug. What does your bulk_insert code look like? On Friday, May 29, 2015 at 1:32:35 AM UTC-4, Ian Ryder wrote: > > OK - I think I have the answer. > > I discovered it wasn't table-specific, it worked with this same method / > table elsewhere in the app. The place it was failing was using

[web2py] Re: _before_insert / update question

2015-05-28 Thread Ian Ryder
OK - I think I have the answer. I discovered it wasn't table-specific, it worked with this same method / table elsewhere in the app. The place it was failing was using bulk_insert. I changed to insert individually and all works fine. Bug? On Friday, May 29, 2015 at 6:39:56 AM UTC+2, Ian Ryder

[web2py] Re: _before_insert / update question

2015-05-28 Thread Ian Ryder
Hi, the key point is I'm not getting passed a dict, I'm getting passed a list. Here's a dump of what the _is_before handler gets passed: [(, datetime.datetime(2015, 5, 29, 6, 32, 27, 732420)), (, 1L), (, 8L), (, 2L), (, 5.0), (, 14093L), (, 'APPEAL'), (, 1L), (, 358001L), (, datetime.datetim

[web2py] Re: _before_insert / update question

2015-05-28 Thread Niphlod
the book shows how to print every argument passed to those functions I dunno how to make the book clearer :°°°D before_insert def this_is_before_insert(some_dict): if 'last_name' in some_dict: some_dict['last_name'] = 'altering' + some_dict['last_name'] db.auth_user._bef

[web2py] Re: _before_insert / update question

2015-05-28 Thread Ian Ryder
OK, think I've solved it. The documentation says a dict passed is into the _before_insert - seems it's a list of lists of [field, value]. I can manipulate the list and the result is what gets written. So perfect - I can do what I need, just I think the documentation needs checking (or I need c

[web2py] Re: _before_insert / update question

2015-05-28 Thread Ian Ryder
Thanks - I couldn't find any documentation / examples and my tests didn't seem to work as expected. Do you know of any examples anywhere I can scan over? I'll have another test in the mean time and update if I get it working On Thursday, May 28, 2015 at 12:02:52 PM UTC+2, Niphlod wrote: > > "mo

[web2py] Re: _before_insert / update question

2015-05-28 Thread Niphlod
"modify data on a record before it's inserted/updated" _before_insert and _before_update take your "near to be committed record" and alter it in memory, then it inserts/update it. Don't know what are you asking for that is different from what web2py does. -- Resources: - http://web2py.com -