Tornado 2.0 新特性¶

Jun 21, 2011¶

  1. Major changes:
  2. * Template output is automatically escaped by default; see backwards
  3. compatibility note below.
  4. * The default AsyncHTTPClient implementation is now simple_httpclient.
  5. * Python 3.2 is now supported.
  6.  
  7. Backwards compatibility:
  8. * Template autoescaping is enabled by default. Applications upgrading from
  9. a previous release of Tornado must either disable autoescaping or adapt
  10. their templates to work with it. For most applications, the simplest
  11. way to do this is to pass autoescape=None to the Application constructor.
  12. Note that this affects certain built-in methods, e.g. xsrf_form_html
  13. and linkify, which must now be called with {% raw %} instead of {}
  14. * Applications that wish to continue using curl_httpclient instead of
  15. simple_httpclient may do so by calling
  16. AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
  17. at the beginning of the process. Users of Python 2.5 will probably want
  18. to use curl_httpclient as simple_httpclient only supports ssl on Python 2.6+.
  19. * Python 3 compatibility involved many changes throughout the codebase,
  20. so users are encouraged to test their applications more thoroughly than
  21. usual when upgrading to this release.
  22.  
  23. Other changes in this release:
  24. * Templates support several new directives:
  25. - {% autoescape ...%} to control escaping behavior
  26. - {% raw ... %} for unescaped output
  27. - {% module ... %} for calling UIModules
  28. * {% module Template(path, **kwargs) %} may now be used to call another
  29. template with an independent namespace
  30. * All IOStream callbacks are now run directly on the IOLoop via add_callback.
  31. * HTTPServer now supports IPv6 where available. To disable, pass
  32. family=socket.AF_INET to HTTPServer.bind().
  33. * HTTPClient now supports IPv6, configurable via allow_ipv6=bool on the
  34. HTTPRequest. allow_ipv6 defaults to false on simple_httpclient and true
  35. on curl_httpclient.
  36. * RequestHandlers can use an encoding other than utf-8 for query parameters
  37. by overriding decode_argument()
  38. * Performance improvements, especially for applications that use a lot of
  39. IOLoop timeouts
  40. * HTTP OPTIONS method no longer requires an XSRF token.
  41. * JSON output (RequestHandler.write(dict)) now sets Content-Type to
  42. application/json
  43. * Etag computation can now be customized or disabled by overriding
  44. RequestHandler.compute_etag
  45. * USE_SIMPLE_HTTPCLIENT environment variable is no longer supported.
  46. Use AsyncHTTPClient.configure instead.

原文:

https://tornado-zh-cn.readthedocs.io/zh_CN/latest/releases/v2.0.0.html