当前位置: 首页>>代码示例>>Python>>正文


Python HTTPBadRequest.status方法代码示例

本文整理汇总了Python中swift.common.swob.HTTPBadRequest.status方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPBadRequest.status方法的具体用法?Python HTTPBadRequest.status怎么用?Python HTTPBadRequest.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swift.common.swob.HTTPBadRequest的用法示例。


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

示例1: GETorHEAD

# 需要导入模块: from swift.common.swob import HTTPBadRequest [as 别名]
# 或者: from swift.common.swob.HTTPBadRequest import status [as 别名]
    def GETorHEAD(self, req):
        """Handler for HTTP GET/HEAD requests."""
        if len(self.account_name) > constraints.MAX_ACCOUNT_NAME_LENGTH:
            resp = HTTPBadRequest(request=req)
            resp.body = 'Account name length of %d longer than %d' % \
                        (len(self.account_name),
                         constraints.MAX_ACCOUNT_NAME_LENGTH)
            return resp

        partition = self.app.account_ring.get_part(self.account_name)
        concurrency = self.app.account_ring.replica_count \
            if self.app.concurrent_gets else 1
        node_iter = self.app.iter_nodes(self.app.account_ring, partition)
        resp = self.GETorHEAD_base(
            req, _('Account'), node_iter, partition,
            req.swift_entity_path.rstrip('/'), concurrency)
        if resp.status_int == HTTP_NOT_FOUND:
            if resp.headers.get('X-Account-Status', '').lower() == 'deleted':
                resp.status = HTTP_GONE
            elif self.app.account_autocreate:
                resp = account_listing_response(self.account_name, req,
                                                get_listing_content_type(req))
        if req.environ.get('swift_owner'):
            self.add_acls_from_sys_metadata(resp)
        else:
            for header in self.app.swift_owner_headers:
                resp.headers.pop(header, None)
        return resp
开发者ID:Ahiknsr,项目名称:swift,代码行数:30,代码来源:account.py

示例2: GETorHEAD

# 需要导入模块: from swift.common.swob import HTTPBadRequest [as 别名]
# 或者: from swift.common.swob.HTTPBadRequest import status [as 别名]
    def GETorHEAD(self, req):
        """Handler for HTTP GET/HEAD requests."""
	print 'in GETorHEAD function of accountcontroller class'
        if len(self.account_name) > constraints.MAX_ACCOUNT_NAME_LENGTH:
            resp = HTTPBadRequest(request=req)
            resp.body = 'Account name length of %d longer than %d' % \
                        (len(self.account_name),
                         constraints.MAX_ACCOUNT_NAME_LENGTH)
            return resp

        partition = self.app.account_ring.get_part(self.account_name)
	print 'partition',partition
        node_iter = self.app.iter_nodes(self.app.account_ring, partition)
	print 'node_iter',node_iter
        resp = self.GETorHEAD_base(
            req, _('Account'), node_iter, partition,
            req.swift_entity_path.rstrip('/'))
	print 'resp',resp
        if resp.status_int == HTTP_NOT_FOUND:
	    print 'resp.status_int == HTTP_NOT_FOUND'
            if resp.headers.get('X-Account-Status', '').lower() == 'deleted':
                resp.status = HTTP_GONE
            elif self.app.account_autocreate:
                resp = account_listing_response(self.account_name, req,
                                                get_listing_content_type(req))
        if req.environ.get('swift_owner'):
	    print 'req.environ.get(swift_owner), true'
            self.add_acls_from_sys_metadata(resp)
        else:
	    for header in self.app.swift_owner_headers:
		print 'header',header
                resp.headers.pop(header, None)
	print 'resp',resp
	print 'in GETorHEAD function of accountcontroller class end'
        return resp
开发者ID:jannatunnoor,项目名称:test_swift,代码行数:37,代码来源:account.py

示例3: GETorHEAD

# 需要导入模块: from swift.common.swob import HTTPBadRequest [as 别名]
# 或者: from swift.common.swob.HTTPBadRequest import status [as 别名]
    def GETorHEAD(self, req):
        """Handler for HTTP GET/HEAD requests."""
        length_limit = self.get_name_length_limit()
        if len(self.account_name) > length_limit:
            resp = HTTPBadRequest(request=req)
            resp.body = b'Account name length of %d longer than %d' % \
                        (len(self.account_name), length_limit)
            # Don't cache this. We know the account doesn't exist because
            # the name is bad; we don't need to cache that because it's
            # really cheap to recompute.
            return resp

        partition = self.app.account_ring.get_part(self.account_name)
        concurrency = self.app.account_ring.replica_count \
            if self.app.concurrent_gets else 1
        node_iter = self.app.iter_nodes(self.app.account_ring, partition)
        params = req.params
        params['format'] = 'json'
        req.params = params
        resp = self.GETorHEAD_base(
            req, _('Account'), node_iter, partition,
            req.swift_entity_path.rstrip('/'), concurrency)
        if resp.status_int == HTTP_NOT_FOUND:
            if resp.headers.get('X-Account-Status', '').lower() == 'deleted':
                resp.status = HTTP_GONE
            elif self.app.account_autocreate:
                # This is kind of a lie; we pretend like the account is
                # there, but it's not. We'll create it as soon as something
                # tries to write to it, but we don't need databases on disk
                # to tell us that nothing's there.
                #
                # We set a header so that certain consumers can tell it's a
                # fake listing. The important one is the PUT of a container
                # to an autocreate account; the proxy checks to see if the
                # account exists before actually performing the PUT and
                # creates the account if necessary. If we feed it a perfect
                # lie, it'll just try to create the container without
                # creating the account, and that'll fail.
                resp = account_listing_response(
                    self.account_name, req,
                    listing_formats.get_listing_content_type(req))
                resp.headers['X-Backend-Fake-Account-Listing'] = 'yes'

        # Cache this. We just made a request to a storage node and got
        # up-to-date information for the account.
        resp.headers['X-Backend-Recheck-Account-Existence'] = str(
            self.app.recheck_account_existence)
        set_info_cache(self.app, req.environ, self.account_name, None, resp)

        if req.environ.get('swift_owner'):
            self.add_acls_from_sys_metadata(resp)
        else:
            for header in self.app.swift_owner_headers:
                resp.headers.pop(header, None)
        return resp
开发者ID:mahak,项目名称:swift,代码行数:57,代码来源:account.py

示例4: GETorHEAD

# 需要导入模块: from swift.common.swob import HTTPBadRequest [as 别名]
# 或者: from swift.common.swob.HTTPBadRequest import status [as 别名]
    def GETorHEAD(self, req):
        """Handler for HTTP GET/HEAD requests."""
        if len(self.account_name) > MAX_ACCOUNT_NAME_LENGTH:
            resp = HTTPBadRequest(request=req)
            resp.body = "Account name length of %d longer than %d" % (len(self.account_name), MAX_ACCOUNT_NAME_LENGTH)
            return resp

        partition, nodes = self.app.account_ring.get_nodes(self.account_name)
        resp = self.GETorHEAD_base(
            req, _("Account"), self.app.account_ring, partition, req.swift_entity_path.rstrip("/")
        )
        if resp.status_int == HTTP_NOT_FOUND:
            if resp.headers.get("X-Account-Status", "").lower() == "deleted":
                resp.status = HTTP_GONE
            elif self.app.account_autocreate:
                resp = account_listing_response(self.account_name, req, get_listing_content_type(req))
        if req.environ.get("swift_owner"):
            self.add_acls_from_sys_metadata(resp)
        else:
            for header in self.app.swift_owner_headers:
                resp.headers.pop(header, None)
        return resp
开发者ID:anishnarang,项目名称:gswift-multinode,代码行数:24,代码来源:account.py

示例5: GETorHEAD

# 需要导入模块: from swift.common.swob import HTTPBadRequest [as 别名]
# 或者: from swift.common.swob.HTTPBadRequest import status [as 别名]
    def GETorHEAD(self, req):
        """Handler for HTTP GET/HEAD requests."""
        if len(self.account_name) > MAX_ACCOUNT_NAME_LENGTH:
            resp = HTTPBadRequest(request=req)
            resp.body = 'Account name length of %d longer than %d' % \
                        (len(self.account_name), MAX_ACCOUNT_NAME_LENGTH)
            return resp

        partition, nodes = self.app.account_ring.get_nodes(self.account_name)
        resp = self.GETorHEAD_base(
            req, _('Account'), self.app.account_ring, partition,
            req.swift_entity_path.rstrip('/'))
        if resp.status_int == HTTP_NOT_FOUND:
            if resp.headers.get('X-Account-Status', '').lower() == 'deleted':
                resp.status = HTTP_GONE
            elif self.app.account_autocreate:
                resp = account_listing_response(self.account_name, req,
                                                get_listing_content_type(req))
        if not req.environ.get('swift_owner', False):
            for key in self.app.swift_owner_headers:
                if key in resp.headers:
                    del resp.headers[key]
        return resp
开发者ID:BlueSkyChina,项目名称:swift,代码行数:25,代码来源:account.py


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