コード例 #1
0
ファイル: swift.py プロジェクト: stoxy/stoxy
    def delete(self, credentials):
        if credentials is None:
            raise BadRequest('Swift backend requires credentials in x-auth-token headers')

        log.debug('Deleting Swift object %s' % self.context.value)
        protocol, schema, host, path = parse_uri(self.context.value)
        uri = "%s:%s%s" % (schema, host, path)
        client.delete_object(uri, credentials, path)
コード例 #2
0
ファイル: manager.py プロジェクト: stoxy/stoxy
    def create(self):
        if self.context.value:
            protocol, schema, host, path = parse_uri(self.context.value)
        else:
            uri, protocol = self.make_uri(self.context)
            self.context.value = uri

        return getAdapter(self.context, IDataStore, protocol)
コード例 #3
0
ファイル: swift.py プロジェクト: stoxy/stoxy
    def save(self, datastream, encoding, credentials):
        if credentials is None:
            raise BadRequest('Swift backend requires credentials in x-auth-token headers')

        log.debug('Saving Swift object %s' % self.context.value)
        protocol, schema, host, path = parse_uri(self.context.value)
        uri = "%s:%s%s" % (schema, host, path)
        client.put_object(uri, credentials, contents=datastream)
        log.debug('Swift object "%s" saved' % self.context.value)
コード例 #4
0
ファイル: swift.py プロジェクト: stoxy/stoxy
    def load(self, credentials):
        if credentials is None:
            raise BadRequest('Swift backend requires credentials in x-auth-token headers')

        log.debug('Loading Swift object %s' % self.context.value)
        protocol, schema, host, path = parse_uri(self.context.value)
        uri = "%s:%s" % (schema, host)
        base_path, objname = path.split('/', 1)
        response, contents = client.get_object(uri, credentials, base_path, objname)
        return StringIO.StringIO(contents)
コード例 #5
0
ファイル: manager.py プロジェクト: stoxy/stoxy
 def save(self, datastream, encoding, credentials=None):
     protocol, schema, host, path = parse_uri(self.context.value)
     assert protocol == 'file', protocol
     assert path, path
     b = 6 * 1024
     log.debug('Writing file: "%s"' % path)
     with open(path, 'wb') as f:
         d = datastream.read(b)
         if encoding == 'base64':
             d = base64.b64decode(d)
         f.write(d)
         while len(d) == b and not datastream.closed:
             d = datastream.read(b)
             f.write(d)
コード例 #6
0
ファイル: manager.py プロジェクト: stoxy/stoxy
 def delete(self, credentials=None):
     protocol, schema, host, path = parse_uri(self.context.value)
     assert protocol == 'null', protocol
     assert path, path
コード例 #7
0
ファイル: manager.py プロジェクト: stoxy/stoxy
    def load(self, credentials=None):
        protocol, schema, host, path = parse_uri(self.context.value)
        assert protocol == 'null', protocol
        assert path, path

        return StringIO.StringIO('')
コード例 #8
0
ファイル: manager.py プロジェクト: stoxy/stoxy
 def save(self, datastream, encoding, credentials=None):
     protocol, schema, host, path = parse_uri(self.context.value)
     assert protocol == 'null', protocol
     assert path, path
コード例 #9
0
ファイル: manager.py プロジェクト: stoxy/stoxy
 def delete(self, credentials=None):
     protocol, schema, host, path = parse_uri(self.context.value)
     assert protocol == 'file', protocol
     assert path, path
     log.debug('Unlinking "%s"' % path)
     os.unlink(path)
コード例 #10
0
ファイル: manager.py プロジェクト: stoxy/stoxy
 def load(self, credentials=None):
     protocol, schema, host, path = parse_uri(self.context.value)
     assert protocol == 'file', protocol
     assert path, path
     return open(path, 'rb')