1. Colin Alston
  2. txriak

Commits

tobixx  committed 2fdcbad

added returnbody

  • Participants
  • Parent commits c7475e8
  • Branches default

Comments (0)

Files changed (1)

File txriak/riak_object.py

View file
         return self._metas
 
     @defer.inlineCallbacks
-    def store(self, w=None, dw=None):
+    def store(self, w=None, dw=None, return_body=True):
         """
         Store the object in Riak. When this operation completes, the
         object could contain new metadata and possibly new data if Riak
                   before returning to client.
         :param dw: Wait for this many partitions to confirm the
                    write before returning to client.
+        :param return_body: Ff the newly stored object should be retrieved again.
 
         :returns: deferred
 
-        .. todo:: pass in 'returnbody' value as parameter.
         .. todo:: make q a parameter.
         """
         # Use defaults if not specified...
         w = self._bucket.get_w(w)
         dw = self._bucket.get_dw(w)
+        return_body = return_body and 'true' or 'false'
 
         # Construct the URL...
-        params = {'returnbody': 'true', 'w': w, 'dw': dw}
+        params = {'returnbody': return_body, 'w': w, 'dw': dw}
         host, port, url = util.build_rest_path(self._client, self._bucket,
                                                     self._key, None, params)
 
                                                          url,
                                                          headers,
                                                          content)
-        self._populate(response, [200, 300])
+        expected = [200, 300]
+        if return_body:
+            expected.append(204)
+
+        self._populate(response, expected)
         defer.returnValue(self)
 
     @defer.inlineCallbacks