David,
The way you're doing it is correct.  As far as I can tell populate is
mostly meant for internal use similar to set_siblings which has this
comment in the code

        Set the array of siblings - used internally

Not sure why they arnt using the convention of setting internal methods
with _ but *shrugs*.
-Michael

On Fri, Sep 28, 2012 at 7:23 PM, David Lowell <d...@go2ctv.com> wrote:

> Hi folks,
>
> Simple question here. Based on the python client documentation, I'm
> unclear on the canonical means to perform in python a read-modify-write
> cycle on an object stored in Riak.
>
> What seems intuitive to me:
>
>     obj = kv.bucket(b).get(name)
>     if f.exists():
>         data = f.get_data()
>         # todo: check for siblings, and resolve
>     else:
>         data = {'my_list': []}
>     data['my_list'].append(something)
>
>     obj.set_data(data)
>     obj.store()
>
> My assumption here is that the RiakObject 'obj' has internally kept the
> vector clock for this key, and when this update gets stored, it will do the
> right thing. However, the documentation doesn't say that's what will
> happen. In fact, I can't find anything in the documentation that makes it
> clear how to do this read-modify-write.
>
> There is this piece of documentation for the python client API:
>
>  |  populate(self, Result)
>  |      Populate the object based on the return from get.
>  |
>  |      If None returned, then object is not found
>  |      If a tuple of vclock, contents then one or more
>  |      whole revisions of the key were found
>  |      If a list of vtags is returned there are multiple
>  |      sibling that need to be retrieved with get.
>
> This is obviously not very clear. This sounds like it has something to do
> with read-modify-write, but who knows.
>
> So, is my intuition in the code above correct? Or should we write back a
> modified object through some other means like populate()?
>
> Thanks for the guidance,
>
> Dave
>
> --
> Dave Lowell
> d...@connectv.com
>
>
> _______________________________________________
> riak-users mailing list
> riak-users@lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>



-- 
-Michael
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to