コード例 #1
0
    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
0
    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
コード例 #3
0
 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
0
 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
コード例 #5
0
    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
コード例 #6
0
    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
コード例 #7
0
ファイル: bucket.py プロジェクト: semk/riak-python-client
    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
コード例 #8
0
ファイル: bucket.py プロジェクト: pipoket/riak-python-client
    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