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


Python Request.subpath方法代码示例

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


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

示例1: test_redirect_to_subdir

# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
 def test_redirect_to_subdir(self):
     from webob import Request
     context = DummyContext()
     from StringIO import StringIO
     request = Request({'PATH_INFO':'',
                        'SCRIPT_NAME':'',
                        'SERVER_NAME':'localhost',
                        'SERVER_PORT':'80',
                        'REQUEST_METHOD':'GET',
                        'wsgi.version':(1,0),
                        'wsgi.url_scheme':'http',
                        'wsgi.input':StringIO()})
     request.subpath = ('static',)
     result = staticapp(context, request)
     self.assertEqual(result.status, '301 Moved Permanently')
     self.assertEqual(result.location, 'http://localhost/static/')
开发者ID:DeanHodgkinson,项目名称:pyramid,代码行数:18,代码来源:test_integration.py

示例2: test_it

# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
 def test_it(self):
     from webob import Request
     context = DummyContext()
     from StringIO import StringIO
     request = Request({'PATH_INFO':'',
                        'SCRIPT_NAME':'',
                        'SERVER_NAME':'localhost',
                        'SERVER_PORT':'80',
                        'REQUEST_METHOD':'GET',
                        'wsgi.version':(1,0),
                        'wsgi.url_scheme':'http',
                        'wsgi.input':StringIO()})
     request.subpath = ['minimal.pt']
     result = staticapp(context, request)
     self.assertEqual(result.status, '200 OK')
     self.assertEqual(
         result.body,
         open(os.path.join(here, 'fixtures/minimal.pt'), 'r').read())
开发者ID:markramm,项目名称:pyramid,代码行数:20,代码来源:test_integration.py

示例3: test_file_in_subdir

# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
 def test_file_in_subdir(self):
     from webob import Request
     context = DummyContext()
     from StringIO import StringIO
     request = Request({'PATH_INFO':'',
                        'SCRIPT_NAME':'',
                        'SERVER_NAME':'localhost',
                        'SERVER_PORT':'80',
                        'REQUEST_METHOD':'GET',
                        'wsgi.version':(1,0),
                        'wsgi.url_scheme':'http',
                        'wsgi.input':StringIO()})
     request.subpath = ('static', 'index.html',)
     result = staticapp(context, request)
     self.assertEqual(result.status, '200 OK')
     self.assertEqual(
         result.body.replace('\r', ''),
         open(os.path.join(here, 'fixtures/static/index.html'), 'r').read())
开发者ID:DeanHodgkinson,项目名称:pyramid,代码行数:20,代码来源:test_integration.py

示例4: test_it

# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
    def test_it(self):
        from webob import Request

        context = DummyContext()
        from StringIO import StringIO

        request = Request(
            {
                "PATH_INFO": "",
                "SCRIPT_NAME": "",
                "SERVER_NAME": "localhost",
                "SERVER_PORT": "80",
                "REQUEST_METHOD": "GET",
                "wsgi.version": (1, 0),
                "wsgi.url_scheme": "http",
                "wsgi.input": StringIO(),
            }
        )
        request.subpath = ["minimal.pt"]
        result = staticapp(context, request)
        self.assertEqual(result.status, "200 OK")
        self.assertEqual(result.body, open(os.path.join(here, "fixtures/minimal.pt"), "r").read())
开发者ID:johnwshipman,项目名称:pyramid,代码行数:24,代码来源:test_integration.py

示例5: test_redirect_to_subdir_with_existing_script_name

# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
    def test_redirect_to_subdir_with_existing_script_name(self):
        from webob import Request

        context = DummyContext()
        from StringIO import StringIO

        request = Request(
            {
                "PATH_INFO": "/static",
                "SCRIPT_NAME": "/script_name",
                "SERVER_NAME": "localhost",
                "SERVER_PORT": "80",
                "REQUEST_METHOD": "GET",
                "wsgi.version": (1, 0),
                "wsgi.url_scheme": "http",
                "wsgi.input": StringIO(),
            }
        )
        request.subpath = ("static",)
        result = staticapp(context, request)
        self.assertEqual(result.status, "301 Moved Permanently")
        self.assertEqual(result.location, "http://localhost/script_name/static/")
开发者ID:niallo,项目名称:pyramid,代码行数:24,代码来源:test_integration.py

示例6: test_file_in_subdir

# 需要导入模块: from webob import Request [as 别名]
# 或者: from webob.Request import subpath [as 别名]
    def test_file_in_subdir(self):
        from webob import Request

        context = DummyContext()
        from StringIO import StringIO

        request = Request(
            {
                "PATH_INFO": "",
                "SCRIPT_NAME": "",
                "SERVER_NAME": "localhost",
                "SERVER_PORT": "80",
                "REQUEST_METHOD": "GET",
                "wsgi.version": (1, 0),
                "wsgi.url_scheme": "http",
                "wsgi.input": StringIO(),
            }
        )
        request.subpath = ("static", "index.html")
        result = staticapp(context, request)
        self.assertEqual(result.status, "200 OK")
        self.assertEqual(
            result.body.replace("\r", ""), open(os.path.join(here, "fixtures/static/index.html"), "r").read()
        )
开发者ID:niallo,项目名称:pyramid,代码行数:26,代码来源:test_integration.py


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