Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

static_url calling in Tornado

I am a beginner to Python and Tornado web framework. When I was studying the template part in the book "Introduction to Tornado", one line confused me:

<link rel="stylesheet" href="{{ static_url("style.css") }}">

How can the application know where to call the function static_url when there is no library imported to the namespace? I found static_url() in Tornado's web module, but I can not figure out how can this function be successfully called in that template file?

like image 943
Kuan Avatar asked Mar 13 '13 15:03

Kuan


1 Answers

The RequestHandler class has a method get_template_namespace(), documented here. If you click the source link then you'll see how it creates a dictionary where 'static_url' is set to self.static_url.

like image 75
Rod Hyde Avatar answered Nov 15 '22 11:11

Rod Hyde