basho/riak-python-client — pull request #243 by seancribbs (2013-04-28 21:01:47+00:00)
Title: Siblings, and other bugs

Three commits, huge and IMO beneficial changes, messages repeated here for your benefit. What can I say, a long plane ride is great for coding.

### Refactor model and handling of siblings.

In order to...

1. Better detect deleted objects and sibling tombstones
2. Reduce server roundtrips to fetch object siblings (which was an inconsistency between HTTP and PBC).

...this refactor introduces breaking changes.

This introduces the `RiakContent` class which models a single sibling. An `RiakObject` that is NOT in conflict will appear to have one "sibling". Objects that are strictly "not found" will have ZERO siblings. Otherwise, the object will have as many siblings as are returned by Riak. This is more consistent with Riak's model of objects (values).

Most existing methods and properties that were on `RiakObject` have been proxied in such a manner that if the object is not in conflict, the corresponding property or method on the solitary sibling will be invoked. When in conflict, these properties and methods with raise the new `riak.ConflictError` exception. Except in the case of conflict, this will ease transition of existing code to the new behavior.

The `get_sibling` method and behavior has been broken to reflect the fact that all siblings are always requested and handled appropriately. The method now produces a deprecation warning and simply returns the requested sibling already in the object. The HTTP transport no longer supports retrieving the "text" format of objects in conflict.

This commit also completes a refactoring of the HTTP transport to break-out transport codec methods into a separate class/file, for clarity and consistency with the PBC transport.

### Correct usage and handling of last_modified metadata.

HTTP and PBC both handled the "Last-Modified" metadatum differently, and `RiakObject` (now `RiakContent`) did not expose it properly. Now both transports convert the metadatum into a floating-point UNIX timestamp (UTC).

### Normalize handling of vector clocks across transports.

This addresses the possibility that an object might be fetched from one interface/transport and stored in the other. Instead, we wrap the raw value in an object that can handle decoding and encoding the format that the transport requires.