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


Python HTTPRequest.get方法代码示例

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


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

示例1: makerequest

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import get [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)
开发者ID:wpjunior,项目名称:proled,代码行数:19,代码来源:makerequest.py

示例2: makerequest

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import get [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)
开发者ID:zopefoundation,项目名称:Zope,代码行数:46,代码来源:makerequest.py

示例3: makeTestRequest

# 需要导入模块: from ZPublisher.HTTPRequest import HTTPRequest [as 别名]
# 或者: from ZPublisher.HTTPRequest.HTTPRequest import get [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
开发者ID:adamcheasley,项目名称:plone.testing,代码行数:22,代码来源:z2.py


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