即將發布的 tornado 2.0 將會帶來哪些特性?


主要更改:

- 模板輸出默認開啟轉義

- AsyncHTTPClient的默認實現現在是simple_httpclient

- 支持Python3.2了

向後兼容性:

- 如果你不想在模板中默認開啟escape,可以在Application構造器中傳一個autoescape=None的參數

- 如果你想繼續使用原來的curl_httpclient而不是simple_httpclient,只需調用AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")

其他小更改:

- 模板中增加如下指令:

* {% autoescape ...%} 控制轉義行為

* {% raw ... %} 表示沒有轉義的輸出

* {% module ... %} 調用UIModules

* {% module Template(path, **kwargs) %} 用於在一個獨立的命名空間中調用另一個模板

- 所有的IOStream調用都走IOLoop,通過add_callback函數追加

- 當IPv6可用時HTTPServer會支持IPv6,禁用它可以把family=socket.AF_INET傳遞給HTTPServer.bind().

- 如果request帶有allow_ipv6=True的話,HTTPClient會支持ipv6.

- 通過重寫decode_argument()方法,RequestHandlers的請求參數可以支持非utf8編碼.

- 性能改進,尤其是使用了很多IOLoop超時的應用程序。

- HTTP的OPTIONS方法不再需要XSRF口令

- JSON 輸出 (RequestHandler.write(dict)) ,現在設置Content-Type為application/json

- Etag指令可以定製或者禁用,通過重寫RequestHandler.compute_etag方法

- 環境變數USE_SIMPLE_HTTPCLIENT不再被支持,使用AsyncHTTPClient.configure代替。


Ben Darnell

I"m planning to release Tornado 2.0 in the near future. If you"d like to

test a release candidate, check out the current source from github and give

it a try.

Draft release notes:

Major changes:

* Template output is automatically escaped by defau< see backwards

compatibility note below.

* The default AsyncHTTPClient implementation is now simple_httpclient.

* Python 3.2 is now supported.

Backwards compatibility:

* Template autoescaping is enabled by default. Applications upgrading from

a previous release of Tornado must either disable autoescaping or adapt

their templates to work with it. For most applications, the simplest

way to do this is to pass autoescape=None to the Application constructor.

* Applications that wish to continue using curl_httpclient instead of

simple_httpclient may do so by calling

AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")

at the beginning of the process.

* Python 3 compatibility involved many changes throughout the codebase,

so users are encouraged to test their applications more thoroughly than

usual when upgrading to this release.

Other changes in this release:

* Templates support several new directives:

- {% autoescape ...%} to control escaping behavior

- {% raw ... %} for unescaped output

- {% module ... %} for calling UIModules

* {% module Template(path, **kwargs) %} may now be used to call another

template with an independent namespace

* All IOStream callbacks are now run directly on the IOLoop via

add_callback.

* HTTPServer now supports IPv6 where available. To disable, pass

family=socket.AF_INET to HTTPServer.bind().

* HTTPClient now supports IPv6 if the request has allow_ipv6=True

* RequestHandlers can use an encoding other than utf-8 for query parameters

by overriding decode_argument()

* Performance improvements, especially for applications that use a lot of

IOLoop timeouts

* HTTP OPTIONS method no longer requires an XSRF token.

* JSON output (RequestHandler.write(dict)) now sets Content-Type to

application/json

* Etag computation can now be customized or disabled by overriding

RequestHandler.compute_etag

* USE_SIMPLE_HTTPCLIENT environment variable is no longer supported.

Use AsyncHTTPClient.configure instead.


推薦閱讀:

第一天——畫一個圓
Fluent Python 筆記(二):序列基礎
2017 夢醒時分
Pyinstaller打包後運行,程序一閃而過,怎麼解決?

TAG:Python | Tornado | WebFramework | Python框架 |