本文整理汇总了Python中riak_object.RiakObject._encode_data方法的典型用法代码示例。如果您正苦于以下问题:Python RiakObject._encode_data方法的具体用法?Python RiakObject._encode_data怎么用?Python RiakObject._encode_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类riak_object.RiakObject
的用法示例。
在下文中一共展示了RiakObject._encode_data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def new(self, key=None, data=None, content_type='application/json'):
"""
Create a new :class:`RiakObject <riak.riak_object.RiakObject>`
that will be stored as JSON. A shortcut for manually
instantiating a :class:`RiakObject
<riak.riak_object.RiakObject>`.
:param key: Name of the key. Leaving this to be None (default)
will make Riak generate the key on store.
:type key: string
:param data: The data to store.
:type data: object
:rtype: :class:`RiakObject <riak.riak_object.RiakObject>`
"""
try:
if isinstance(data, basestring):
data = data.encode('ascii')
except UnicodeError:
raise TypeError('Unicode data values are not supported.')
obj = RiakObject(self._client, self, key)
obj.set_data(data)
obj.set_content_type(content_type)
obj._encode_data = True
return obj
示例2: get_binary
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def get_binary(self, key, r=None):
"""
Retrieve a binary/string object from Riak.
@param string key - Name of the key.
@param int r - R-Value of the request (defaults to bucket's R)
@return RiakObject
"""
obj = RiakObject(self._client, self, key)
obj._encode_data = False
r = self.get_r(r)
return obj.reload(r)
示例3: new
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def new(self, key, data=None, content_type='application/json'):
"""
Create a new Riak object that will be stored as JSON.
@param string key - Name of the key.
@param object data - The data to store. (default None)
@return RiakObject
"""
obj = RiakObject(self._client, self, key)
obj.set_data(data)
obj.set_content_type(content_type)
obj._encode_data = True
return obj
示例4: get_binary
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def get_binary(self, key, r=None):
"""
Retrieve a binary/string object from Riak.
:param key: Name of the key.
:type key: string
:param r: R-Value of the request (defaults to bucket's R)
:type r: integer
:rtype: :class:`RiakObject <riak.riak_object.RiakObject>`
"""
obj = RiakObject(self._client, self, key)
obj._encode_data = False
r = self.get_r(r)
return obj.reload(r)
示例5: new_binary
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def new_binary(self, key, data, content_type='application/octet-stream'):
"""
Create a new Riak object that will be stored as plain text/binary.
@param string key - Name of the key.
@param object data - The data to store.
@param string content_type - The content type of the object.
(default 'application/octet-stream')
@return RiakObject
"""
obj = RiakObject(self._client, self, key)
obj.set_data(data)
obj.set_content_type(content_type)
obj._encode_data = False
return obj
示例6: get
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def get(self, key, r=None, pr=None):
"""
Retrieve a JSON-encoded object from Riak.
:param key: Name of the key.
:type key: string
:param r: R-Value of the request (defaults to bucket's R)
:type r: integer
:param pr: PR-Value of the request (defaults to bucket's PR)
:type pr: integer
:rtype: :class:`RiakObject <riak.riak_object.RiakObject>`
"""
obj = RiakObject(self._client, self, key)
obj._encode_data = True
return obj.reload(r=r, pr=pr)
示例7: new
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def new(self, key, data=None, content_type='application/json'):
"""
Create a new :class:`RiakObject <riak.riak_object.RiakObject>` that will be stored as JSON. A shortcut for
manually instantiating a :class:`RiakObject <riak.riak_object.RiakObject>`.
:param key: Name of the key.
:type key: string
:param data: The data to store.
:type data: object
:rtype: :class:`RiakObject <riak.riak_object.RiakObject>`
"""
obj = RiakObject(self._client, self, key)
obj.set_data(data)
obj.set_content_type(content_type)
obj._encode_data = True
return obj
示例8: new_binary
# 需要导入模块: from riak_object import RiakObject [as 别名]
# 或者: from riak_object.RiakObject import _encode_data [as 别名]
def new_binary(self, key, data, content_type="application/octet-stream"):
"""
Create a new :class:`RiakObject <riak.riak_object.RiakObject>` that will be stored as plain text/binary.
A shortcut for manually instantiating a :class:`RiakObject <riak.riak_object.RiakObject>`.
:param key: Name of the key.
:type key: string
:param data: The data to store.
:type data: object
:param content_type: The content type of the object.
:type content_type: string
:rtype: :class:`RiakObject <riak.riak_object.RiakObject>`
"""
obj = RiakObject(self._client, self, key)
obj.set_data(data)
obj.set_content_type(content_type)
obj._encode_data = False
return obj