• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python base.headers_to_container_info函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中swift.proxy.controllers.base.headers_to_container_info函数的典型用法代码示例。如果您正苦于以下问题:Python headers_to_container_info函数的具体用法?Python headers_to_container_info怎么用?Python headers_to_container_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了headers_to_container_info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_headers_to_container_info_values

    def test_headers_to_container_info_values(self):
        headers = {
            "x-container-read": "readvalue",
            "x-container-write": "writevalue",
            "x-container-sync-key": "keyvalue",
            "x-container-meta-access-control-allow-origin": "here",
        }
        resp = headers_to_container_info(headers.items(), 200)
        self.assertEquals(resp["read_acl"], "readvalue")
        self.assertEquals(resp["write_acl"], "writevalue")
        self.assertEquals(resp["cors"]["allow_origin"], "here")

        headers["x-unused-header"] = "blahblahblah"
        self.assertEquals(resp, headers_to_container_info(headers.items(), 200))
开发者ID:r0mik,项目名称:swift,代码行数:14,代码来源:test_base.py


示例2: get_container_info

    def get_container_info(self, app):
        """
        get_container_info will return a result dict of get_container_info
        from the backend Swift.

        :returns: a dictionary of container info from
                  swift.controllers.base.get_container_info
        :raises: NoSuchBucket when the container doesn't exist
        :raises: InternalError when the request failed without 404
        """
        if self.is_authenticated:
            # if we have already authenticated, yes we can use the account
            # name like as AUTH_xxx for performance efficiency
            sw_req = self.to_swift_req(app, self.container_name, None)
            info = get_container_info(sw_req.environ, app)
            if is_success(info['status']):
                return info
            elif info['status'] == 404:
                raise NoSuchBucket(self.container_name)
            else:
                raise InternalError(
                    'unexpected status code %d' % info['status'])
        else:
            # otherwise we do naive HEAD request with the authentication
            resp = self.get_response(app, 'HEAD', self.container_name, '')
            return headers_to_container_info(
                resp.sw_headers, resp.status_int)  # pylint: disable-msg=E1101
开发者ID:notmyname,项目名称:swift3,代码行数:27,代码来源:request.py


示例3: test_headers_to_container_info_meta

 def test_headers_to_container_info_meta(self):
     headers = {'X-Container-Meta-Whatevs': 14,
                'x-container-meta-somethingelse': 0}
     resp = headers_to_container_info(headers.items(), 200)
     self.assertEqual(len(resp['meta']), 2)
     self.assertEqual(resp['meta']['whatevs'], 14)
     self.assertEqual(resp['meta']['somethingelse'], 0)
开发者ID:mahak,项目名称:swift,代码行数:7,代码来源:test_base.py


示例4: test_headers_to_container_info_sys_meta

 def test_headers_to_container_info_sys_meta(self):
     prefix = get_sys_meta_prefix("container")
     headers = {"%sWhatevs" % prefix: 14, "%ssomethingelse" % prefix: 0}
     resp = headers_to_container_info(headers.items(), 200)
     self.assertEquals(len(resp["sysmeta"]), 2)
     self.assertEquals(resp["sysmeta"]["whatevs"], 14)
     self.assertEquals(resp["sysmeta"]["somethingelse"], 0)
开发者ID:helen5haha,项目名称:swift,代码行数:7,代码来源:test_base.py


示例5: GETorHEAD

    def GETorHEAD(self, req):
        """Handler for HTTP GET/HEAD requests."""
        if not self.account_info(self.account_name, req)[1]:
            return HTTPNotFound(request=req)
        part = self.app.container_ring.get_part(
            self.account_name, self.container_name)
        resp = self.GETorHEAD_base(
            req, _('Container'), self.app.container_ring, part, req.path_info)
        if self.app.memcache:
            # set the memcache container size for ratelimiting
            cache_key = get_container_memcache_key(self.account_name,
                                                   self.container_name)
            self.app.memcache.set(
                cache_key,
                headers_to_container_info(resp.headers, resp.status_int),
                time=self.app.recheck_container_existence)

        if 'swift.authorize' in req.environ:
            req.acl = resp.headers.get('x-container-read')
            aresp = req.environ['swift.authorize'](req)
            if aresp:
                return aresp
        if not req.environ.get('swift_owner', False):
            for key in ('x-container-read', 'x-container-write',
                        'x-container-sync-key', 'x-container-sync-to'):
                if key in resp.headers:
                    del resp.headers[key]
        return resp
开发者ID:DrLeonard,项目名称:swift,代码行数:28,代码来源:container.py


示例6: test_headers_to_container_info_values

    def test_headers_to_container_info_values(self):
        headers = {
            'x-container-read': 'readvalue',
            'x-container-write': 'writevalue',
            'x-container-sync-key': 'keyvalue',
            'x-container-meta-access-control-allow-origin': 'here',
        }
        resp = headers_to_container_info(headers.items(), 200)
        self.assertEqual(resp['read_acl'], 'readvalue')
        self.assertEqual(resp['write_acl'], 'writevalue')
        self.assertEqual(resp['cors']['allow_origin'], 'here')

        headers['x-unused-header'] = 'blahblahblah'
        self.assertEqual(
            resp,
            headers_to_container_info(headers.items(), 200))
开发者ID:mahak,项目名称:swift,代码行数:16,代码来源:test_base.py


示例7: test_container_info_in_response_env

 def test_container_info_in_response_env(self):
     controller = proxy_server.ContainerController(self.app, "a", "c")
     with mock.patch("swift.proxy.controllers.base.http_connect", fake_http_connect(200, 200, body="")):
         req = Request.blank("/v1/a/c", {"PATH_INFO": "/v1/a/c"})
         resp = controller.HEAD(req)
     self.assertEqual(2, resp.status_int // 100)
     self.assertTrue("swift.container/a/c" in resp.environ)
     self.assertEqual(headers_to_container_info(resp.headers), resp.environ["swift.container/a/c"])
开发者ID:prashanthpai,项目名称:gluster-swift,代码行数:8,代码来源:test_container.py


示例8: test_headers_to_container_info_sys_meta

 def test_headers_to_container_info_sys_meta(self):
     prefix = get_sys_meta_prefix('container')
     headers = {'%sWhatevs' % prefix: 14,
                '%ssomethingelse' % prefix: 0}
     resp = headers_to_container_info(headers.items(), 200)
     self.assertEqual(len(resp['sysmeta']), 2)
     self.assertEqual(resp['sysmeta']['whatevs'], 14)
     self.assertEqual(resp['sysmeta']['somethingelse'], 0)
开发者ID:mahak,项目名称:swift,代码行数:8,代码来源:test_base.py


示例9: test_container_info_in_response_env

 def test_container_info_in_response_env(self):
     controller = proxy_server.ContainerController(self.app, 'a', 'c')
     with mock.patch('swift.proxy.controllers.base.http_connect',
                     fake_http_connect(200, 200, body='')):
         req = Request.blank('/a/c', {'PATH_INFO': '/a/c'})
         resp = controller.HEAD(req)
     self.assertEqual(2, resp.status_int // 100)
     self.assertTrue("swift.container/a/c" in resp.environ)
     self.assertEqual(headers_to_container_info(resp.headers),
                      resp.environ['swift.container/a/c'])
开发者ID:Awingu,项目名称:swift,代码行数:10,代码来源:test_container.py


示例10: __init__

 def __init__(self, headers, env, account, container):
     self.headers = headers
     self.status_int = FakeResponse_status_int
     self.environ = env
     cache_key, env_key = _get_cache_key(account, container)
     if container:
         info = headers_to_container_info(headers, FakeResponse_status_int)
     else:
         info = headers_to_account_info(headers, FakeResponse_status_int)
     env[env_key] = info
开发者ID:r0mik,项目名称:swift,代码行数:10,代码来源:test_base.py


示例11: test_container_info

 def test_container_info(self):
     req = Request.blank('/v1/a/c', {'PATH_INFO': '/v1/a/c'}, method='HEAD')
     self.storage.container.container_show = Mock(return_value={})
     resp = req.get_response(self.app)
     self.assertEqual(2, resp.status_int // 100)
     self.assertIn('swift.infocache', resp.environ)
     self.assertIn('container/a/c', resp.environ['swift.infocache'])
     self.assertEqual(
         headers_to_container_info(resp.headers, resp.status_int),
         resp.environ['swift.infocache']['container/a/c'])
开发者ID:fvennetier,项目名称:oio-swift,代码行数:10,代码来源:test_container.py


示例12: test_container_info_got_cached

 def test_container_info_got_cached(self):
     controller = proxy_server.ContainerController(self.app, "a", "c")
     with mock.patch("swift.proxy.controllers.base.http_connect", fake_http_connect(200, 200, body="")):
         req = Request.blank("/v1/a/c", {"PATH_INFO": "/v1/a/c"})
         resp = controller.HEAD(req)
     self.assertEqual(2, resp.status_int // 100)
     # Make sure it's in both swift.infocache and memcache
     self.assertIn("container/a/c", resp.environ["swift.infocache"])
     self.assertEqual(headers_to_container_info(resp.headers), resp.environ["swift.infocache"]["container/a/c"])
     from_memcache = self.app.memcache.get("container/a/c")
     self.assertTrue(from_memcache)
开发者ID:prashanthpai,项目名称:swift,代码行数:11,代码来源:test_container.py


示例13: _mock_infocache

    def _mock_infocache(self, env):
        if not self.skip_metadata:
            return

        req = Request(env)
        # don't fake obj metadata
        account, container, _ = self._extract_path(req.path_info)
        req.environ.setdefault('swift.infocache', {})
        req.environ['swift.infocache'][get_cache_key(account)] = \
            headers_to_account_info({}, 0)
        if container:
            key = get_cache_key(account, container)
            req.environ['swift.infocache'][key] = \
                headers_to_container_info({}, 0)
开发者ID:jfsmig,项目名称:oio-swift,代码行数:14,代码来源:autocontainerbase.py


示例14: test_container_info_got_cached

 def test_container_info_got_cached(self):
     controller = proxy_server.ContainerController(self.app, 'a', 'c')
     with mock.patch('swift.proxy.controllers.base.http_connect',
                     fake_http_connect(200, 200, body='')):
         req = Request.blank('/v1/a/c', {'PATH_INFO': '/v1/a/c'})
         resp = controller.HEAD(req)
     self.assertEqual(2, resp.status_int // 100)
     # Make sure it's in both swift.infocache and memcache
     self.assertIn("container/a/c", resp.environ['swift.infocache'])
     self.assertEqual(
         headers_to_container_info(resp.headers),
         resp.environ['swift.infocache']['container/a/c'])
     from_memcache = self.app.memcache.get('container/a/c')
     self.assertTrue(from_memcache)
开发者ID:ISCAS-VDI,项目名称:swift-base,代码行数:14,代码来源:test_container.py


示例15: __init__

    def __init__(self, headers, env, account, container, obj):
        self.headers = headers
        self.status_int = FakeResponse_status_int
        self.environ = env
        if obj:
            env_key = get_object_env_key(account, container, obj)
        else:
            cache_key, env_key = _get_cache_key(account, container)

        if account and container and obj:
            info = headers_to_object_info(headers, FakeResponse_status_int)
        elif account and container:
            info = headers_to_container_info(headers, FakeResponse_status_int)
        else:
            info = headers_to_account_info(headers, FakeResponse_status_int)
        env[env_key] = info
开发者ID:10389030,项目名称:swift,代码行数:16,代码来源:test_base.py


示例16: test_memcached_container_info_dict

 def test_memcached_container_info_dict(self):
     mdict = headers_to_container_info({"x-container-object-count": "45"})
     self.assertEqual(mdict["object_count"], "45")
开发者ID:notmyname,项目名称:swift,代码行数:3,代码来源:test_ratelimit.py


示例17: test_headers_to_container_info_missing

 def test_headers_to_container_info_missing(self):
     resp = headers_to_container_info({}, 404)
     self.assertEquals(resp["status"], 404)
     self.assertEquals(resp["read_acl"], None)
     self.assertEquals(resp["write_acl"], None)
开发者ID:r0mik,项目名称:swift,代码行数:5,代码来源:test_base.py


示例18: test_headers_to_container_info_meta

 def test_headers_to_container_info_meta(self):
     headers = {"X-Container-Meta-Whatevs": 14, "x-container-meta-somethingelse": 0}
     resp = headers_to_container_info(headers.items(), 200)
     self.assertEquals(len(resp["meta"]), 2)
     self.assertEquals(resp["meta"]["whatevs"], 14)
     self.assertEquals(resp["meta"]["somethingelse"], 0)
开发者ID:r0mik,项目名称:swift,代码行数:6,代码来源:test_base.py


示例19: test_headers_to_container_info_missing

 def test_headers_to_container_info_missing(self):
     resp = headers_to_container_info({}, 404)
     self.assertEqual(resp['status'], 404)
     self.assertIsNone(resp['read_acl'])
     self.assertIsNone(resp['write_acl'])
开发者ID:mahak,项目名称:swift,代码行数:5,代码来源:test_base.py


示例20: test_memcached_container_info_dict

 def test_memcached_container_info_dict(self):
     mdict = headers_to_container_info({'x-container-object-count': '45'})
     self.assertEquals(mdict['object_count'], '45')
开发者ID:BlueSkyChina,项目名称:swift,代码行数:3,代码来源:test_ratelimit.py



注:本文中的swift.proxy.controllers.base.headers_to_container_info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.headers_to_object_info函数代码示例发布时间:2022-05-27
下一篇:
Python base.headers_to_account_info函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap