コード例 #1
0
 def _setter(self, value):
     if len(self.siblings) == 0:
         # In this case, assume that what the user wants is to
         # create a new sibling inside an empty object.
         self.siblings = [RiakContent(self)]
     if len(self.siblings) != 1:
         raise ConflictError()
     setattr(self.siblings[0], name, value)
コード例 #2
0
    def store(self,
              w=None,
              dw=None,
              pw=None,
              return_body=True,
              if_none_match=False,
              timeout=None):
        """
        Store the object in Riak. When this operation completes, the
        object could contain new metadata and possibly new data if Riak
        contains a newer version of the object according to the object's
        vector clock.

        :param w: W-value, wait for this many partitions to respond
         before returning to client.
        :type w: integer
        :param dw: DW-value, wait for this many partitions to
         confirm the write before returning to client.
        :type dw: integer

        :param pw: PW-value, require this many primary partitions to
                   be available before performing the put
        :type pw: integer
        :param return_body: if the newly stored object should be
                            retrieved
        :type return_body: bool
        :param if_none_match: Should the object be stored only if
                              there is no key previously defined
        :type if_none_match: bool
        :param timeout: a timeout value in milliseconds
        :type timeout: int
        :rtype: :class:`RiakObject` """
        if len(self.siblings) != 1:
            raise ConflictError("Attempting to store an invalid object, "
                                "resolve the siblings first")

        self.client.put(self,
                        w=w,
                        dw=dw,
                        pw=pw,
                        return_body=return_body,
                        if_none_match=if_none_match,
                        timeout=timeout)

        return self
コード例 #3
0
 def _delegate(self, *args, **kwargs):
     if len(self.siblings) != 1:
         raise ConflictError()
     return getattr(self.siblings[0], name).__call__(*args, **kwargs)
コード例 #4
0
 def _getter(self):
     if len(self.siblings) == 0:
         return
     if len(self.siblings) != 1:
         raise ConflictError()
     return getattr(self.siblings[0], name)