Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jinja template auto reloading does not work. #5

Open
mjmare opened this issue May 26, 2015 · 2 comments
Open

Jinja template auto reloading does not work. #5

mjmare opened this issue May 26, 2015 · 2 comments
Labels

Comments

@mjmare
Copy link

mjmare commented May 26, 2015

I have a settings section (as per docs) like:

@App.setting_section(section='jinja2')
def get_setting_section():
    return {
      'auto_reload': True,
      'autoescape': True,
      'extensions': ['jinja2.ext.autoescape']
    }

But changes to ninja templates are not automatically reloaded on page reload. The whole app needs to be restarted for the changes to show.

@faassen faassen added the bug label May 27, 2015
@faassen
Copy link
Member

faassen commented May 27, 2015

Okay, this implies something must be going on with the way settings are passed in. The default for jinja2 is to have autoreload on, but more.jinja2 turns this off in its own get_setting_section code. It's possible that for some reason this setting doesn't get overridden by your own setting section call.

To help debug this, could you try changing the code in more.jinja2 directly that sets the auto_reload to False and make it be True? If it works then, then we know we have a problem overriding settings. If it doesn't work, then we for some reason break the template reloading in Jinja2 in general.

@mjmare
Copy link
Author

mjmare commented May 29, 2015

As per your instruction I tried setting auto_reload to True in both
get_setting_section and get_jinja2_loader(template_directories, settings) in more.jinja2/more/jinja2/main.py. Didn't work.
I tried setting a breakpoint in ninja2....-egg/jinja2/environment.py and found that auto_reload kwarg was set to True. So it seems that the configuration process is OK.
Breaking in get_jinja2_render(loader, name, original_render) I see that the template object correctly detects changes to the template (as indicated by the template.is_up_to_date property). However stale content is returned.
I won't pretend to understand what's going on at the end of get_jinja2_render....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants