Articles Tagged tornado

Tornado and pgettext

Tornado and pgettext

Recently (26.05.2015) new tornado 4.2 was released. It contains different updates, the most valuable i suppose are modules tornado.locks and tornado.queues. They migrated from package Toro, look detailed explanation in Jesse Jiryu Davis post.

Here i want to tell about another helpful function, that was added with my help - pgettext.

It can be useful, when you are creating the translation for ambiguous strings. Let's say we have word "bat ...

Posted on 2015-06-05

Tornado i18n and l10n

Tornado i18n and i10n

Let's talk about i18n, i10n and tornado implementation. This post have a lot of text, but i wanted to describe many things that i faced during realization of i18n in tornado project. The step by step instruction is placed in the second part of this article.

Common definitions


i18n - shorthand from internationalization. It mean the process of multiple languages support in application. It is not the translation itself, but technical part of the ...

Posted on 2015-01-31

Set url for Tornado handlers

Set url for Tornado handlers

To set url for tornado handlers we can pass list of tuples (url regex, handler) into application initialisation:

application = tornado.web.Application([
    (r"/", MainHandler),
    (r"/some/path/page/(?P<pk>[0-9]+)$", PageHandler),

But it is more convenient to use wrapper tornado.web.url, that allows to assign meaningful names for paths (similar to django url).

Nevertheless, in a couple of production projects that i had to work with, this wrapper wasn't used. Also in ...

Posted on 2014-12-15

Async Bitcoin RPC client

To work with Bitcoin RPC from python there is a library Python-BitcoinRPC.

But recently i need to call API from tornado application. Mentioned lib works in synchronous, i.e. blocking mode. For tornado it will be much better to use asynchronous version. Tried to search for existing solution, but can't find it. So i create my async fork, that use tornado's AsyncHTTPClient:

Example (print current number of blocks ...

Posted on 2014-01-30

Tornado web application example

Tornado web application example

Tornado - async web framework for python. I'll cover shortly pros and cons about tornado and introduce typical web project, that is built on top of it.

By describing pros and cons i mean my own point of view in compare with django.

Tornado pros

1. Asynchronous.

In tornado core there is a infinite loop called "ioloop", that listen for events. All that happens in one single thread. For example, somebody wants to fetch /home ...

Posted on 2013-12-29