Commits

Anonymous committed 5338030

Add ability to get key and bucket from a RiakObject to both PHP and Python clients, fix bug in RiakLink in Python client.

  • Participants
  • Parent commits 26061c3

Comments (0)

Files changed (4)

File client_lib/php/riak.php

   }
 
   /**
-   * Get the R-value setting for this ClientObject. (default 2)
+   * Get the R-value setting for this RiakClient. (default 2)
    * @return integer
    */
   function getR() { 
   }
 
   /**
-   * Set the R-value for this ClientObject. This value will be used
+   * Set the R-value for this RiakClient. This value will be used
    * for any calls to get(...) or getBinary(...) where where 1) no
    * R-value is specified in the method call and 2) no R-value has
-   * been set in the BucketObject.  
+   * been set in the RiakBucket.  
    * @param integer $r - The R value.
    * @return $this
    */
   }
 
   /**
-   * Get the W-value setting for this ClientObject. (default 2)
+   * Get the W-value setting for this RiakClient. (default 2)
    * @return integer
    */
   function getW() { 
   }
 
   /**
-   * Set the W-value for this ClientObject. See setR(...) for a
+   * Set the W-value for this RiakClient. See setR(...) for a
    * description of how these values are used.
    * @param integer $w - The W value.
    * @return $this
   }
 
   /**
-   * Set the DW-value for this ClientObject. See setR(...) for a
+   * Set the DW-value for this RiakClient. See setR(...) for a
    * description of how these values are used.
    * @param  integer $dw - The DW value.
    * @return $this
   }
 
   /**
-   * Get the clientID for this ClientObject.
+   * Get the clientID for this RiakClient.
    * @return string
    */
   function getClientID() { 
   }
 
   /**
-   * Set the clientID for this ClientObject. Should not be called
+   * Set the clientID for this RiakClient. Should not be called
    * unless you know what you are doing.
    * @param string $clientID - The new clientID.
    * @return $this
 
   /**
    * Get the bucket by the specified name. Since buckets always exist,
-   * this will always return a BucketObject.
+   * this will always return a RiakBucket.
    * @return RiakBucket
    */
   function bucket($name) {
   }
 
   /**
-   * Check if the Riak server for this ClientObject is alive.
+   * Check if the Riak server for this RiakClient is alive.
    * @return boolean
    */
   function isAlive() {
     $this->dw = NULL;
   }
 
+  /**
+   * Get the bucket name.
+   */
+  function getName() {
+    return $this->name;
+  }
+
   /** 
    * Get the R-value for this bucket, if it is set, otherwise return
    * the R-value for the client.
   }
 
   /**
+   * Get the bucket of this object.
+   * @return RiakBucket
+   */
+  function getBucket() {
+    return $this->bucket;
+  }
+
+  /**
+   * Get the key of this object.
+   * @return string
+   */
+  function getKey() {
+    return $this->key;
+  }
+
+  /**
    * Get the data stored in this object. Will return a associative
    * array, unless the object was constructed with newBinary(...) or
    * getBinary(...), in which case this will return a string.
   }
 
   /**
-   * Given a ClientObject, BucketObject, Key, LinkSpec, and Params,
+   * Given a RiakClient, RiakBucket, Key, LinkSpec, and Params,
    * construct and return a URL.
    */
   public static function buildRestPath($client, $bucket, $key=NULL, $spec=NULL, $params=NULL) {

File client_lib/php/unit_tests.php

   $obj->store();
 
   $obj = $bucket->get('foo');
-  
   test_assert($obj->exists());
+  test_assert($obj->getBucket()->getName() == 'bucket');
+  test_assert($obj->getKey() == 'foo');
   test_assert($obj->getData() == $rand);
 }
 

File client_lib/python/riak.py

 
         def get_r(self):
                 """
-                Get the R-value setting for this ClientObject. (default 2)
+                Get the R-value setting for this RiakClient. (default 2)
                 @return integer
                 """
                 return self._r
 
         def set_r(self, r):
                 """
-                Set the R-value for this ClientObject. This value will be used
+                Set the R-value for this RiakClient. This value will be used
                 for any calls to get(...) or get_binary(...) where where 1) no
                 R-value is specified in the method call and 2) no R-value has
-                been set in the BucketObject.
+                been set in the RiakBucket.
                 @param integer r - The R value.
                 @return self
                 """
 
         def get_w(self):
                 """
-                Get the W-value setting for this ClientObject. (default 2)
+                Get the W-value setting for this RiakClient. (default 2)
                 @return integer
                 """
                 return self._w
 
         def set_w(self, w):
                 """
-                Set the W-value for this ClientObject. See set_r(...) for a
+                Set the W-value for this RiakClient. See set_r(...) for a
                 description of how these values are used.
                 @param integer w - The W value.
                 @return self
         
         def set_dw(self, dw):
                 """
-                Set the DW-value for this ClientObject. See set_r(...) for a
+                Set the DW-value for this RiakClient. See set_r(...) for a
                 description of how these values are used.
                 @param integer dw - The DW value.
                 @return self
         
         def get_client_id(self):
                 """
-                Get the client_id for this ClientObject.
+                Get the client_id for this RiakClient.
                 @return string
                 """
                 return self._client_id
         
         def set_client_id(self, client_id):
                 """
-                Set the client_id for this ClientObject. Should not be called
+                Set the client_id for this RiakClient. Should not be called
                 unless you know what you are doing.
                 @param string client_id - The new client_id.
                 @return self
         def bucket(self, name):
                 """
                 Get the bucket by the specified name. Since buckets always exist,
-                this will always return a BucketObject.
+                this will always return a RiakBucket.
                 @return RiakBucket
                 """
                 return RiakBucket(self, name)
         
         def is_alive(self):
                 """
-                Check if the Riak server for this ClientObject is alive.
+                Check if the Riak server for this RiakClient is alive.
                 @return boolean
                 """
                 response = RiakUtils.http_request('GET', self._host, self._port, '/ping')
                 @param integer r - The R-value to use.
                 @return RiakObject
                 """
-                return self._client._bucket(self._bucket).get(self._key, r)
+                return self._client.bucket(self._bucket).get(self._key, r)
 
         def get_binary(self, r=None):
                 """
                 @param integer r - The R-value to use.
                 @return RiakObject
                 """
-                return self._client._bucket(self._bucket).get_binary(self._key, r)
+                return self._client.bucket(self._bucket).get_binary(self._key, r)
 
         def get_bucket(self):
                 """
                 self._dw = None
                 return None
 
+        def get_name(self):
+                """
+                Get the bucket name.
+                """
+                return self._name
+
         def get_r(self, r=None):
                 """
                 Get the R-value for this bucket, if it is set, otherwise return
                 self._exists = False
                 return None
 
+        def get_bucket(self):
+                """
+                Get the bucket of this object.
+                @return RiakBucket
+                """
+                return self._bucket;
+
+        def get_key(self):
+                """
+                Get the key of this object.
+                @return string
+                """
+                return self._key
+
+
         def get_data(self):
                 """
                 Get the data stored in this object. Will return a associative
         @classmethod
         def build_rest_path(self, client, bucket, key=None, spec=None, params=None) :
                 """
-                Given a ClientObject, BucketObject, Key, LinkSpec, and Params,
+                Given a RiakClient, RiakBucket, Key, LinkSpec, and Params,
                 construct and return a URL.		
                 """
                 # Build 'http://hostname:port/prefix/bucket'

File client_lib/python/unit_tests.py

 	obj.store()
 	obj = bucket.get('foo')
 	assert(obj.exists())
+        assert(obj.get_bucket().get_name() == 'bucket')
+        assert(obj.get_key() == 'foo')
 	assert(obj.get_data() == rand)
 
 def test_binary_store_and_get():