本文整理汇总了Python中ZPublisher.HTTPRequest.HTTPRequest._steps方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPRequest._steps方法的具体用法?Python HTTPRequest._steps怎么用?Python HTTPRequest._steps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZPublisher.HTTPRequest.HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest._steps方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addRequestContainer
# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import _steps [as 别名]
def addRequestContainer(app, environ=None):
"""Add the request container with a fake request to the app object's
acquisition context and return the wrapped app object. Additional request
environment values can be passed as a dict ``environ``.
"""
from sys import stdin, stdout
from ZPublisher.HTTPRequest import HTTPRequest
from ZPublisher.HTTPResponse import HTTPResponse
from ZPublisher.BaseRequest import RequestContainer
from zope.publisher.browser import setDefaultSkin
if environ is None:
environ = {}
environ.setdefault('SERVER_NAME', 'nohost')
environ.setdefault('SERVER_PORT', 'port')
environ.setdefault('REQUEST_METHOD', 'GET')
resp = HTTPResponse(stdout=stdout)
req = HTTPRequest(stdin, environ, resp)
req._steps = ['noobject'] # Fake a published object.
setDefaultSkin(req)
requestcontainer = RequestContainer(REQUEST=req)
return app.__of__(requestcontainer)
示例2: testRequest
# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import _steps [as 别名]
def testRequest():
"""Create a new request object. This is based on the code in
:py:func`Testing.makerequest.makerequest`."""
import sys
from ZPublisher.HTTPRequest import HTTPRequest
from ZPublisher.HTTPResponse import HTTPResponse
environ = {"SERVER_NAME": "localhost",
"SERVER_PORT": "80",
"REQUEST_METHOD": "GET"}
request = HTTPRequest(sys.stdin, environ, HTTPResponse())
request._steps = ["Plone"]
return request
示例3: makerequest
# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import _steps [as 别名]
def makerequest(app, stdout=stdout):
resp = HTTPResponse(stdout=stdout)
environ = os.environ.copy()
environ['SERVER_NAME'] = 'foo'
environ['SERVER_PORT'] = '80'
environ['REQUEST_METHOD'] = 'GET'
req = HTTPRequest(stdin, environ, resp)
req._steps = ['noobject'] # Fake a published object.
req['ACTUAL_URL'] = req.get('URL') # Zope 2.7.4
# set Zope3-style default skin so that the request is usable for
# Zope3-style view look-ups.
from zope.app.publication.browser import setDefaultSkin
setDefaultSkin(req)
requestcontainer = RequestContainer(REQUEST = req)
return app.__of__(requestcontainer)
示例4: makerequest
# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import _steps [as 别名]
def makerequest(app, stdout=None, environ=None):
"""
Adds an HTTPRequest at app.REQUEST, and returns
app.__of__(app.REQUEST). Useful for tests that need to acquire
REQUEST.
Usage:
import makerequest
app = makerequest.makerequest(app)
You should only wrap the object used as 'root' in your tests.
app is commonly a Zope2.app(), but that's not strictly necessary
and frequently may be overkill; you can wrap other objects as long
as they support acquisition and provide enough of the features of
Zope2.app for your tests to run. For example, if you want to call
getPhysicalPath() on child objects, app must provide a
non-recursive implementation of getPhysicalPath().
*stdout* is an optional file-like object and is used by
REQUEST.RESPONSE. The default is sys.stdout.
*environ* is an optional mapping to be used in the request.
Default is a fresh dictionary. Passing os.environ is not
recommended; tests should not pollute the real os.environ.
"""
if stdout is None:
stdout = BytesIO()
if environ is None:
environ = {}
resp = HTTPResponse(stdout=stdout)
environ.setdefault('SERVER_NAME', 'nohost')
environ.setdefault('SERVER_PORT', '80')
environ.setdefault('REQUEST_METHOD', 'GET')
req = HTTPRequest(BytesIO(), environ, resp)
req._steps = ['noobject'] # Fake a published object.
req['ACTUAL_URL'] = req.get('URL') # Zope 2.7.4
# Set default skin so that the request is usable for view look-ups.
from zope.publisher.browser import setDefaultSkin
setDefaultSkin(req)
requestcontainer = RequestContainer(REQUEST=req)
return app.__of__(requestcontainer)
示例5: makeTestRequest
# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import _steps [as 别名]
def makeTestRequest(environ=None):
"""Return an HTTPRequest object suitable for testing views."""
from sys import stdin, stdout
from ZPublisher.HTTPRequest import HTTPRequest
from ZPublisher.HTTPResponse import HTTPResponse
from zope.publisher.browser import setDefaultSkin
if environ is None:
environ = {}
environ.setdefault('SERVER_NAME', 'foo')
environ.setdefault('SERVER_PORT', '80')
environ.setdefault('REQUEST_METHOD', 'GET')
resp = HTTPResponse(stdout=stdout)
req = HTTPRequest(stdin, environ, resp)
req._steps = ['noobject'] # Fake a published object.
req['ACTUAL_URL'] = req.get('URL')
setDefaultSkin(req)
return req