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


Python Website.handle_safely方法代码示例

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


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

示例1: __call__

# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import handle_safely [as 别名]
    def __call__(self, path='/', *a):
        """Given an URL path, return

        This only allows you to simulate GET requests with no querystring, so
        it's limited. But it's a something. Kind of. Almost.

        """
        website = Website(self.argv + list(a))
        request = StubRequest(path)
        request.website = website
        response = website.handle_safely(request)
        return response
开发者ID:rayleyva,项目名称:aspen,代码行数:14,代码来源:__init__.py

示例2: test_configuration_script_can_set_renderer_default

# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import handle_safely [as 别名]
def test_configuration_script_can_set_renderer_default():
    CONFIG = """
website.renderer_default="stdlib_format"
    """
    SIMPLATE = """
name="program"
[----]
Greetings, {name}!
    """
    mk(
       ('.aspen/configure-aspen.py', CONFIG),
       ('index.html.spt', SIMPLATE)
      )
    w = Website(['--www_root', FSFIX, '-p', fix('.aspen'), '--show_tracebacks=yes'])
    request = StubRequest(b'/')
    request.website = w
    response = w.handle_safely(request)
    actual = response.body.strip()
    expected = 'Greetings, program!'
    assert actual == expected, actual
开发者ID:ArmstrongJ,项目名称:aspen-python,代码行数:22,代码来源:test_configuration.py

示例3: test_double_failure_still_sets_response_dot_request

# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import handle_safely [as 别名]
def test_double_failure_still_sets_response_dot_request():
    mk( '.aspen'
      , ('.aspen/foo.py', """
def bar(response):
    response.request
""")
      , ( '.aspen/configure-aspen.py'
        , 'import foo\nwebsite.hooks.outbound.append(foo.bar)'
         )
      , ('index.html.spt', "raise heck\n[---]\n")
       )

    # Intentionally break the website object so as to trigger a double failure.
    project_root = os.path.join(FSFIX, '.aspen')
    website = Website(['--www_root='+FSFIX, '--project_root='+project_root])
    del website.renderer_factories

    response = website.handle_safely(StubRequest())

    expected = 500
    actual = response.code
    assert actual == expected, actual
开发者ID:Web5design,项目名称:aspen-python,代码行数:24,代码来源:test_website.py

示例4: bar

# 需要导入模块: from aspen.website import Website [as 别名]
# 或者: from aspen.website.Website import handle_safely [as 别名]
      , ('.aspen/foo.py', """
def bar(response):
    response.request
""")
      , ( '.aspen/configure-aspen.py'
        , 'import foo\nwebsite.hooks.outbound.append(foo.bar)'
         )
      , ('index.html', "raise heck")
       )

    # Intentionally break the website object so as to trigger a double failure.
    project_root = os.path.join(FSFIX, '.aspen')
    website = Website(['--www_root='+FSFIX, '--project_root='+project_root])
    del website.renderer_factories

    response = website.handle_safely(StubRequest())

    expected = 500
    actual = response.code
    assert actual == expected, actual


def test_website_doesnt_clobber_outbound():
    mk( ( '.aspen/configure-aspen.py'
        , 'import random\nwebsite.hooks.outbound.append(random.choice)'
         )
       )

    project_root = os.path.join(FSFIX, '.aspen')
    website = Website(['--www_root='+FSFIX, '--project_root='+project_root])
开发者ID:gunshor,项目名称:aspen,代码行数:32,代码来源:test_website.py


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