Creating lazy properties outside the request handler

26 views
Skip to first unread message

wataka

unread,
Feb 10, 2012, 3:20:49 AM2/10/12
to Tornado Web Server
Where can one create globally available properties/variables in
Tornado that can vary during runtime? I cannot use the request
handlers because a third party module would need need to use this data
for some calculations before passing it on the a request handler if
necessary. The settings instance is only read once when the
application is started, that would not work. Any ideas?

Thanks

Aleksandar Radulovic

unread,
Feb 10, 2012, 5:01:03 AM2/10/12
to python-...@googlegroups.com
How about the application class itself? Every handler has access to
the application its running under.

-alex

--
a lex 13 x
http://a13x.net | @a13xnet

Emilio Daniel González

unread,
Feb 10, 2012, 6:34:15 AM2/10/12
to python-...@googlegroups.com
Hi Wataka! As Alex suggests, I use the application instance:

Into a handler method...

self.application.<your needed attribute> = <your cross handlers data>

Take in account that is a good practice having multiple instance of tornado, in that escenario you'll need to manage your common data with another solution.

~e

wataka

unread,
Feb 10, 2012, 1:46:19 PM2/10/12
to Tornado Web Server
Thanks guys!
Reply all
Reply to author
Forward
0 new messages