Which is the preferred method to use jinja2 on App Engine?

前端 未结 4 2049
感动是毒
感动是毒 2021-02-20 15:24

I originally implemented Jinja2 on App Engine using the examples shown on the App Engine site here: https://developers.google.com/appengine/docs/python/gettingstartedpython27/te

4条回答
  •  离开以前
    2021-02-20 16:03

    TL;DR: Use option #2

    If you don't use i18n, then it doesn't matter much. But in the real world people speak different languages than English, and there is a tricky issue with jinja2 i18n on GAE: Threading (i.e. threadsafe: true in app.yaml) is on by default and important for performance, but most jinja2 i18n docs that you can find on the web are not thread safe. Since you don't want to explicitly pass down the locale to each jinja2 macro, it needs to be held in a thread-local variable. This is what webapp2_extras.jinja2 does correctly.

提交回复
热议问题