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


Python HTTPRequest.traverse方法代码示例

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


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

示例1: test_default_viewname_overrides_fti

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import traverse [as 别名]
    def test_default_viewname_overrides_fti(self):
        response = HTTPResponse()
        environment = { 'URL': '',
                        'PARENTS': [self.site],
                        'REQUEST_METHOD': 'GET',
                        'SERVER_PORT': '80',
                        'REQUEST_METHOD': 'GET',
                        'steps': [],
                        'SERVER_NAME': 'localhost',
                        '_hacked_path': 0 }
        r = HTTPRequest(StringIO(), environment, response)
        r.other.update(environment)

        # we define a Zope3-style default view name for which a view
        # actually exists
        defineDefaultViewName('index.html', IDummyContent)
        try:
            from zope.component import provideAdapter
            provideAdapter(DummyView, (DummyContent, IBrowserRequest),
                           IBrowserView, 'index.html')
        except ImportError:
            # BBB for Zope 2.8
            from zope.app.tests import ztapi
            ztapi.browserView(IDummyContent, 'index.html', DummyView)

        r.traverse('foo')
        self.assertEqual( r.URL, '/foo/index.html' )
        self.assertEqual( r.response.base, '/foo/' )
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: test_default_view_from_fti

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import traverse [as 别名]
    def test_default_view_from_fti(self):
        response = HTTPResponse()
        environment = { 'URL': '',
                        'PARENTS': [self.site],
                        'REQUEST_METHOD': 'GET',
                        'SERVER_NAME': 'localhost',
                        'SERVER_PORT': '80',
                        'REQUEST_METHOD': 'GET',
                        'steps': [],
                        '_hacked_path': 0}
        r = HTTPRequest(StringIO(), environment, response)
        r.other.update(environment)

        r.traverse('foo')
        self.assertEqual( r.URL, '/foo/dummy_view' )
        self.assertEqual( r.response.base, '/foo/',
                          'CMF Collector issue #192 (wrong base): %s'
                          % (r.response.base or 'empty',) )
开发者ID:,项目名称:,代码行数:20,代码来源:

示例3: test_default_viewname_but_no_view_doesnt_override_fti

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import traverse [as 别名]
    def test_default_viewname_but_no_view_doesnt_override_fti(self):
        response = HTTPResponse()
        environment = { 'URL': '',
                        'PARENTS': [self.site],
                        'REQUEST_METHOD': 'GET',
                        'SERVER_NAME': 'localhost',
                        'SERVER_PORT': '80',
                        'REQUEST_METHOD': 'GET',
                        'steps': [],
                        '_hacked_path': 0 }
        r = HTTPRequest(StringIO(), environment, response)
        r.other.update(environment)

        # we define a Zope3-style default view name, but no
        # corresponding view, no change in behaviour expected
        defineDefaultViewName('index.html', IDummyContent)
        r.traverse('foo')
        self.assertEqual( r.URL, '/foo/dummy_view' )
        self.assertEqual( r.response.base, '/foo/' )
开发者ID:,项目名称:,代码行数:21,代码来源:


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