2013/6/19 Cédric Krier <[email protected]>
> Hi,
>
> In the same idea as the changeset [1], I would like to propose this
> change for the write method:
>
sounds good
> @classmethod
> def write(cls, records, values):
> …
>
> =>
>
> @classmethod
> def write(cls, records, values, *args):
> assert not len(args) % 2
> all_records = []
> actions = iter((records, values) + args)
> for records, values in zip(actions, actions):
> …
> all_records += records
>
> cls._validate(all_records)
>
I don't understand the treatment of 'actions'. Which extra arguments can be
expected?
This has two advantages:
>
> - call validate for a larger set of records which will benefit of
> the prefetching
> - reduce the number of RPC calls
>
The only cons I found is if you want to set a value (the same) to a lot of
records (for example, set the state of a list of 'order' records after
processed their lines.
But I understand that there are more cases where it is an improvement.
It could be possible to get this behaviour using 'active record'?
An usage example:
for move in todo_moves:
move.quantity += 3
...
save(todo_moves)
No more wishes for now ;-)
--
Guillem Barba
http://www.guillem.alcarrer.net