Python tornado.escape.recursive_unicode() Examples
The following are 27
code examples of tornado.escape.recursive_unicode().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tornado.escape
, or try the search function
.
Example #1
Source File: web_test.py From EventGhost with GNU General Public License v2.0 | 6 votes |
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)))
Example #2
Source File: web_test.py From honeything with GNU General Public License v3.0 | 6 votes |
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)))
Example #3
Source File: web_test.py From viewfinder with Apache License 2.0 | 6 votes |
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)))
Example #4
Source File: web_test.py From viewfinder with Apache License 2.0 | 6 votes |
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)))
Example #5
Source File: web_test.py From tornado-zh with MIT License | 6 votes |
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)))
Example #6
Source File: httpserver_test.py From viewfinder with Apache License 2.0 | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #7
Source File: httpserver_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
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)
Example #8
Source File: httpserver_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def post(self): self.write(recursive_unicode(self.request.arguments))
Example #9
Source File: httpserver_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #10
Source File: escape_test.py From EventGhost with GNU General Public License v2.0 | 5 votes |
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"))
Example #11
Source File: httpserver_test.py From honeything with GNU General Public License v3.0 | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #12
Source File: httpserver_test.py From pySINDy with MIT License | 5 votes |
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)
Example #13
Source File: httpserver_test.py From pySINDy with MIT License | 5 votes |
def post(self): self.write(recursive_unicode(self.request.arguments))
Example #14
Source File: httpserver_test.py From pySINDy with MIT License | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #15
Source File: httpserver_test.py From teleport with Apache License 2.0 | 5 votes |
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)
Example #16
Source File: httpserver_test.py From teleport with Apache License 2.0 | 5 votes |
def post(self): self.write(recursive_unicode(self.request.arguments))
Example #17
Source File: httpserver_test.py From teleport with Apache License 2.0 | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #18
Source File: httpserver_test.py From viewfinder with Apache License 2.0 | 5 votes |
def post(self): self.write(recursive_unicode(self.request.arguments))
Example #19
Source File: httpserver_test.py From viewfinder with Apache License 2.0 | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #20
Source File: httpserver_test.py From tornado-zh with MIT License | 5 votes |
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)
Example #21
Source File: httpserver_test.py From tornado-zh with MIT License | 5 votes |
def post(self): self.write(recursive_unicode(self.request.arguments))
Example #22
Source File: httpserver_test.py From tornado-zh with MIT License | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #23
Source File: escape_test.py From tornado-zh with MIT License | 5 votes |
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"))
Example #24
Source File: httpserver_test.py From tornado-zh with MIT License | 5 votes |
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)
Example #25
Source File: httpserver_test.py From tornado-zh with MIT License | 5 votes |
def post(self): self.write(recursive_unicode(self.request.arguments))
Example #26
Source File: httpserver_test.py From tornado-zh with MIT License | 5 votes |
def get(self): self.write(recursive_unicode(self.request.arguments))
Example #27
Source File: escape_test.py From tornado-zh with MIT License | 5 votes |
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"))