Good catch on that, Steve.


On Fri, May 9, 2014 at 12:09 PM, Joshua Carp <notifications@github.com>wrote:

> In modularodm/writequeue.py:
>
> > @@ -0,0 +1,67 @@
> > +import copy
> > +import logging
> > +
> > +
> > +logger = logging.getLogger(__name__)
> > +
> > +
> > +class WriteAction(object):
> > +
> > +    def __init__(self, method, *args, **kwargs):
> > +        if not callable(method):
> > +            raise TypeError('Argument `method` must be callable')
> > +        self.method = method
> > +        self.args = copy.deepcopy(args)
>
> Just in case they get mutated after a write action is added to the queue:
>
> Model.start_queue()record = Model()record.save()  # The `insert` action is enqueuedrecord.data['foo'] = 'bar'  # Potentially mutates the saved dataModel.commit_queue()
>
> The commit should save the data that was enqueued, not the data that was
> changed after save was called.
>
> Now that you mention it, though, I see that handling mutation weirdness is
> already the responsibility of Field::to_storage--mutable values are
> deep-copied when they get serialized. So yeah, we shouldn't need the copy
> here.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/CenterForOpenScience/modular-odm/pull/88/files#r12482837>
> .
>