Ejemplo n.º 1
0
    def store(self, data, blob):
        if not isinstance(data, unicode):
            raise NotStorable("Could not store data (not of 'unicode' "
                              "type).")

        data = data.encode('UTF-8')
        StringStorable.store(self, data, blob)
Ejemplo n.º 2
0
    def store(self, data, blob):
        if not isinstance(data, str):
            raise NotStorable("Could not store data (not of 'str' type).")

        fp = blob.open('w')
        fp.write(data)
        fp.close()
Ejemplo n.º 3
0
    def store(self, data, blob):
        if not isinstance(data, file):
            raise NotStorable('Could not store data (not of "file").')

        filename = getattr(data, 'name', None)
        if filename is not None:
            blob.consumeFile(filename)
            return
Ejemplo n.º 4
0
    def store(self, data, blob):
        if not isinstance(data, file):
            raise NotStorable("Could not store data (not of 'file').")

        filename = getattr(data, "name", None)
        if filename is not None:
            blob.consumeFile(filename)
            return
Ejemplo n.º 5
0
    def store(self, data, blob):
        if not isinstance(data, TemporaryFileWrapper):
            msg = 'Could not store data (not of TemporaryFileWrapper type)'
            raise NotStorable(msg)

        filename = getattr(data, 'name', None)
        if filename is not None:
            blob.consumeFile(filename)
Ejemplo n.º 6
0
    def store(self, data, blob):
        raw = data.raw
        if not isinstance(raw, io.FileIO):
            raise NotStorable('Could not store data (not of type "io.FileIO")')

        filename = getattr(data.raw, 'name', None)
        if filename is not None:
            blob.consumeFile(filename)
            return
Ejemplo n.º 7
0
    def store(self, data, blob):
        if not isinstance(data, FileChunk):
            raise NotStorable('Could not store data (not a of "FileChunk" type).')  # noqa

        with blob.open('w') as fp:
            chunk = data
            while chunk:
                fp.write(chunk._data)
                chunk = chunk.next
Ejemplo n.º 8
0
    def store(self, data, blob):
        if not isinstance(data, FileChunk):
            raise NotStorable("Could not store data (not a of 'FileChunk' "
                              "type).")

        fp = blob.open('w')
        chunk = data
        while chunk:
            fp.write(chunk._data)
            chunk = chunk.next
        fp.close()
Ejemplo n.º 9
0
    def store(self, data, blob):
        if not isinstance(data, FileUpload):
            raise NotStorable('Could not store data (not of "FileUpload").')

        data.seek(0)

        with blob.open('w') as fp:
            block = data.read(MAXCHUNKSIZE)
            while block:
                fp.write(block)
                block = data.read(MAXCHUNKSIZE)
Ejemplo n.º 10
0
    def store(self, data, blob):
        if not isinstance(data, FileUpload):
            raise NotStorable("Could not store data (not of 'FileUpload').")

        data.seek(0)

        fp = blob.open('w')
        block = data.read(MAXCHUNKSIZE)
        while block:
            fp.write(block)
            block = data.read(MAXCHUNKSIZE)
        fp.close()
Ejemplo n.º 11
0
    def store(self, data, blob):
        if not isinstance(data, file):
            raise NotStorable("Could not store data (not of 'file').")

        # The original used consumeFile which tries to move a file if possible
        # filename = getattr(data, "name", None)
        # if filename is not None:
        #     blob.consumeFile(filename)
        #     return
        # Let us use any file object and just copy it
        import logging
        logging.getLogger("BLOB PATCH").info("USE MY BLOB STORAGE ADAPTER")
        dest = blob.open('w')
        # TODO: should we seek to 0?
        shutil.copyfileobj(data, dest)
Ejemplo n.º 12
0
    def store(self, data, blob):
        if not isinstance(data, _TemporaryFileWrapper):
            raise NotStorable('Could not store data (not a '
                              '"_TemporaryFileWrapper").')

        _chunked_transfer(data, blob)
Ejemplo n.º 13
0
 def store(self, pdata, blob):
     if not isinstance(pdata, Pdata):
         raise NotStorable('Could not store data (not of "Pdata").')
     fp = blob.open('w')
     fp.write(str(pdata))
     fp.close()
Ejemplo n.º 14
0
    def store(self, data, blob):
        if not isinstance(data, six.text_type):
            raise NotStorable('Could not store data (not of "unicode" type).')

        data = data.encode('UTF-8')
        StringStorable.store(self, data, blob)
Ejemplo n.º 15
0
    def store(self, data, blob):
        if not isinstance(data, str):
            raise NotStorable('Could not store data (not of "str" type).')

        with blob.open('w') as fp:
            fp.write(data)
Ejemplo n.º 16
0
    def store(self, data, blob):
        if not isinstance(data, FileUpload):
            raise NotStorable('Could not store data (not of "FileUpload").')

        _chunked_transfer(data, blob)
Ejemplo n.º 17
0
    def store(self, data, blob):
        if not isinstance(data, six.binary_type):
            raise NotStorable('Could not store data (not of bytes type).')

        with blob.open('w') as fp:
            fp.write(data)