Unfortunately that does seem to be the way the code ends up looking. In fact,
one gotcha I've noticed is that obj.exists() will be False when
obj.has_siblings() is True. So, you'd probably want to swap your ifs around,
like:
obj = bucket.get("mykey")
if obj.has_siblings():
# do conflict resolution
elif obj.exists():
obj.set_data(data)
else:
obj = bucket.new("mykey", data=data)
obj.store() # Also note here that return_body=True by default, and even if you
specify return_body=False, the http transport actually ignores this! I have an
outstanding pull request on github which fixes this.
At the SF Riak Meetup a couple weeks ago, the Yammer guys complained about the
client library support for Scala / Java. And the Python library leaves much to
be desired too. It is on github, though, so we should all feel free to
contribute to it and make it better.
On Friday, April 1, 2011 at 10:08 AM, Eric Moritz wrote:
> Does anyone have a standard pattern for working with allow_mult with
> the Python library? I feels a bit awkward to me. I assume I need to
> do the following:
>
> data = {"foo": "bar"}
> obj = bucket.get("mykey")
>
> if not obj.exists():
> obj = bucket.new("mykey", data=data)
> else:
> if obj.has_siblings():
> # do conflict resolution
> else:
> obj.set_data(data)
>
> obj.store()
>
> Is the the way to do it? If so, that seems like a lot of boiler plating to me.
>
> Eric.
>
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com