本文整理汇总了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/' )
示例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',) )
示例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/' )