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


Python HTTPRequest.close方法代码示例

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


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

示例1: testRemoveStdinReferences

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import close [as 别名]
 def testRemoveStdinReferences(self):
     # Verifies that all references to the input stream go away on
     # request.close().  Otherwise a tempfile may stick around.
     import sys
     from StringIO import StringIO
     s = StringIO(TEST_FILE_DATA)
     env = TEST_ENVIRON.copy()
     start_count = sys.getrefcount(s)
     from ZPublisher.HTTPRequest import HTTPRequest
     req = HTTPRequest(s, env, None)
     req.processInputs()
     self.assertNotEqual(start_count, sys.getrefcount(s))  # Precondition
     req.close()
     self.assertEqual(start_count, sys.getrefcount(s))  # The test
开发者ID:wpjunior,项目名称:proled,代码行数:16,代码来源:testHTTPRequest.py

示例2: publish_module_standard

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import close [as 别名]
def publish_module_standard(
        module_name,
        stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
        environ=os.environ, debug=0, request=None, response=None):
    must_die = 0
    status = 200
    after_list = [None]
    try:
        try:
            if response is None:
                response = Response(stdout=stdout, stderr=stderr)
            else:
                stdout = response.stdout

            # debug is just used by tests (has nothing to do with debug_mode!)
            response.handle_errors = not debug

            if request is None:
                request = Request(stdin, environ, response)

            setRequest(request)

            # make sure that the request we hand over has the
            # default layer/skin set on it; subsequent code that
            # wants to look up views will likely depend on it
            if ISkinnable.providedBy(request):
                setDefaultSkin(request)

            response = publish(request, module_name, after_list, debug=debug)
        except (SystemExit, ImportError):
            # XXX: Rendered ImportErrors were never caught here because they
            # were re-raised as string exceptions. Maybe we should handle
            # ImportErrors like all other exceptions. Currently they are not
            # re-raised at all, so they don't show up here.
            must_die = sys.exc_info()
            request.response.exception(1)
        except:
            # debug is just used by tests (has nothing to do with debug_mode!)
            if debug:
                raise
            request.response.exception()
            status = response.getStatus()

        if response:
            outputBody = getattr(response, 'outputBody', None)
            if outputBody is not None:
                outputBody()
            else:
                response = str(response)
                if response:
                    stdout.write(response)

        # The module defined a post-access function, call it
        if after_list[0] is not None:
            after_list[0]()

    finally:
        if request is not None:
            request.close()
            clearRequest()

    if must_die:
        # Try to turn exception value into an exit code.
        try:
            if hasattr(must_die[1], 'code'):
                code = must_die[1].code
            else:
                code = int(must_die[1])
        except:
            code = must_die[1] and 1 or 0
        if hasattr(request.response, '_requestShutdown'):
            request.response._requestShutdown(code)

        try:
            reraise(must_die[0], must_die[1], must_die[2])
        finally:
            must_die = None

    return status
开发者ID:zopefoundation,项目名称:ZServer,代码行数:81,代码来源:Publish.py


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