swiftly/client/localclient.py
def request(self, method, path, contents, headers, decode_json=False,
                stream=False, query=None, cdn=False):
        """
        See :py:func:`swiftly.client.client.Client.request`
        """
        if cdn:
            raise Exception('CDN not yet supported with LocalClient')
        if isinstance(contents, six.string_types):
            contents = StringIO(contents)
        if not headers:
            headers = {}
        if not query:
            query = {}
        rpath = path.lstrip('/')
        if '/' in rpath:
            container_name, object_name = rpath.split('/', 1)
        else:
            container_name = rpath
            object_name = ''
        if not container_name:
            status, reason, hdrs, body = self._account(
                method, contents, headers, stream, query, cdn)
        elif not object_name:
            status, reason, hdrs, body = self._container(
                method, container_name, contents, headers, stream, query, cdn)
        else:
            status, reason, hdrs, body = self._object(
                method, container_name, object_name, contents, headers, stream,
                query, cdn)
        if status and status // 100 != 5:
            if not stream and decode_json and status // 100 == 2:
                if body:
                    body = loads(body)
                else:
                    body = None
            return (status, reason, hdrs, body)
        raise Exception('%s %s failed: %s %s' % (method, path, status, reason))
def request(self, method, path, contents, headers, decode_json=False,
                stream=False, query=None, cdn=False):
        """
        See :py:func:`swiftly.client.client.Client.request`
        """
        if cdn:
            raise Exception('CDN not yet supported with LocalClient')
        if isinstance(contents, six.string_types):
            contents = StringIO(contents)
        if not headers:
            headers = {}
        if not query:
            query = {}
        rpath = path.lstrip('/')
        if '/' in rpath:
            container_name, object_name = rpath.split('/', 1)
        else:
            container_name = rpath
            object_name = ''
        if not container_name:
            status, reason, hdrs, body = self._account(
                method, contents, headers, stream, query, cdn)
        elif not object_name:
            status, reason, hdrs, body = self._container(
                method, container_name, contents, headers, stream, query, cdn)
        else:
            status, reason, hdrs, body = self._object(
                method, container_name, object_name, contents, headers, stream,
                query, cdn)
        if status and status // 100 != 5:
            if not stream and decode_json and status // 100 == 2:
                if body:
                    body = loads(body)
                else:
                    body = None
            return (status, reason, hdrs, body)
        raise Exception('%s %s failed: %s %s' % (method, path, status, reason))
See :py:func:`swiftly.client.client.Client.request`