librelist archives

« back to archive

How to disable jinja2's auto_reload?

How to disable jinja2's auto_reload?

From:
Young King
Date:
2011-09-13 @ 10:26
I notice that jinja2 's auto_reload is set True by default, it's not  a good
choice for the production use.

It seems that flask didn't supply configuration for jinja2,  how can I turn
off the `auto_reload` in the flask?


-- 
Blog : http://blog.flyzen.com
Twitter: http://twitter.com/wayhome
Sina:  http://t.sina.com.cn/wayhome
douban: http://www.douban.com/people/wayhome/

Re: [flask] How to disable jinja2's auto_reload?

From:
Alex Morega
Date:
2011-09-13 @ 11:15
On Sep 13, 2011, at 1:26 PM, Young King wrote:

> I notice that jinja2 's auto_reload is set True by default, it's not  a 
good choice for the production use.
> 
> It seems that flask didn't supply configuration for jinja2,  how can I 
turn off the `auto_reload` in the flask? 

You can overwrite jinja_options and set `auto_reload` to False:

app.jinja_options = dict(app.jinja_options, auto_reload=False)

Not sure if this is a good idea though, because the jinja_options you're 
overriding is an ImmutableDict for some reason.

Cheers,
-- Alex

Re: [flask] How to disable jinja2's auto_reload?

From:
Simon Sapin
Date:
2011-09-13 @ 14:00
Le 13/09/2011 13:15, Alex Morega a écrit :
> You can overwrite jinja_options and set `auto_reload` to False:
>
> app.jinja_options = dict(app.jinja_options, auto_reload=False)
>
> Not sure if this is a good idea though, because the jinja_options you're
overriding is an ImmutableDict for some reason.

Hi,

Flask.jinja_options is a class attribute and thus shared by all 
instances. That’s why it’s immutable. Your code sample add an attribute 
on a given instance, which masks the class attribute. It’s safe as this 
one is not shared by other instances.

Regards,
-- 
Simon Sapin