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


Python escape.recursive_unicode方法代码示例

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


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

示例1: get

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import recursive_unicode [as 别名]
def get(self, *path_args):
        # Type checks: web.py interfaces convert argument values to
        # unicode strings (by default, but see also decode_argument).
        # In httpserver.py (i.e. self.request.arguments), they're left
        # as bytes.  Keys are always native strings.
        for key in self.request.arguments:
            if type(key) != str:
                raise Exception("incorrect type for key: %r" % type(key))
            for value in self.request.arguments[key]:
                if type(value) != bytes:
                    raise Exception("incorrect type for value: %r" %
                                    type(value))
            for value in self.get_arguments(key):
                if type(value) != unicode_type:
                    raise Exception("incorrect type for value: %r" %
                                    type(value))
        for arg in path_args:
            if type(arg) != unicode_type:
                raise Exception("incorrect type for path arg: %r" % type(arg))
        self.write(dict(path=self.request.path,
                        path_args=path_args,
                        args=recursive_unicode(self.request.arguments))) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:24,代码来源:web_test.py

示例2: get

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import recursive_unicode [as 别名]
def get(self, *path_args):
        # Type checks: web.py interfaces convert argument values to
        # unicode strings (by default, but see also decode_argument).
        # In httpserver.py (i.e. self.request.arguments), they're left
        # as bytes.  Keys are always native strings.
        for key in self.request.arguments:
            if type(key) != str:
                raise Exception("incorrect type for key: %r" % type(key))
            for value in self.request.arguments[key]:
                if type(value) != bytes_type:
                    raise Exception("incorrect type for value: %r" %
                                    type(value))
            for value in self.get_arguments(key):
                if type(value) != unicode_type:
                    raise Exception("incorrect type for value: %r" %
                                    type(value))
        for arg in path_args:
            if type(arg) != unicode_type:
                raise Exception("incorrect type for path arg: %r" % type(arg))
        self.write(dict(path=self.request.path,
                        path_args=path_args,
                        args=recursive_unicode(self.request.arguments))) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:24,代码来源:web_test.py

示例3: get

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import recursive_unicode [as 别名]
def get(self, *path_args):
        # Type checks: web.py interfaces convert argument values to
        # unicode strings (by default, but see also decode_argument).
        # In httpserver.py (i.e. self.request.arguments), they're left
        # as bytes.  Keys are always native strings.
        for key in self.request.arguments:
            assert type(key) == str, repr(key)
            for value in self.request.arguments[key]:
                assert type(value) == bytes_type, repr(value)
            for value in self.get_arguments(key):
                assert type(value) == unicode, repr(value)
        for arg in path_args:
            assert type(arg) == unicode, repr(arg)
        self.write(dict(path=self.request.path,
                        path_args=path_args,
                        args=recursive_unicode(self.request.arguments))) 
开发者ID:omererdem,项目名称:honeything,代码行数:18,代码来源:web_test.py

示例4: test_recursive_unicode

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import recursive_unicode [as 别名]
def test_recursive_unicode(self):
        tests = {
            'dict': {b"foo": b"bar"},
            'list': [b"foo", b"bar"],
            'tuple': (b"foo", b"bar"),
            'bytes': b"foo"
        }
        self.assertEqual(recursive_unicode(tests['dict']), {u("foo"): u("bar")})
        self.assertEqual(recursive_unicode(tests['list']), [u("foo"), u("bar")])
        self.assertEqual(recursive_unicode(tests['tuple']), (u("foo"), u("bar")))
        self.assertEqual(recursive_unicode(tests['bytes']), u("foo")) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:13,代码来源:escape_test.py

示例5: get

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import recursive_unicode [as 别名]
def get(self):
        self.write(recursive_unicode(self.request.arguments)) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:4,代码来源:httpserver_test.py

示例6: post

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import recursive_unicode [as 别名]
def post(self):
        self.write(recursive_unicode(self.request.arguments)) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:4,代码来源:httpserver_test.py

示例7: test_malformed_body

# 需要导入模块: from tornado import escape [as 别名]
# 或者: from tornado.escape import recursive_unicode [as 别名]
def test_malformed_body(self):
        # parse_qs is pretty forgiving, but it will fail on python 3
        # if the data is not utf8.  On python 2 parse_qs will work,
        # but then the recursive_unicode call in EchoHandler will
        # fail.
        if str is bytes:
            return
        with ExpectLog(gen_log, 'Invalid x-www-form-urlencoded body'):
            response = self.fetch(
                '/echo', method="POST",
                headers={'Content-Type': 'application/x-www-form-urlencoded'},
                body=b'\xe9')
        self.assertEqual(200, response.code)
        self.assertEqual(b'{}', response.body) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:16,代码来源:httpserver_test.py


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