Google App Engine中的Jinja2 [英] Jinja2 in Google App Engine
问题描述
我已经开始在Google App Engine上使用 Jinja2 作为我的模板引擎(在Python中)。
我的问题是:字节码缓存是否会在生产环境中工作?它在开发服务器上运行得非常好,但是我在某处读取字节码缓存取决于 marshal
模块,这在App Engine中不受支持。 这个答案给另一个问题提供了一个通过更改 marshal
以使用 pickle
方法,可能的解决方案。有没有人试过这个?
一般来说,在App Engine中使用Jinja2时还有什么需要考虑的?
任何帮助将不胜感激!
谢谢。
Rodrigo Moraes在GAE下为Jinja2创建了一些特殊的装载机,请参阅此处。它不是字节码缓存,但是它将所有模板预编译为Python,因此避免了Jinja2的解析开销。
请注意(来自此GAE页面):
$ b
已编译的应用程序代码已被缓存
快速响应网页请求
I have started using Jinja2 as my templating engine on Google App Engine (in Python).
My question is this: Will bytecode caching work in production? It is working very well on the development server, but I read somewhere that bytecode caching depends on the marshal
module, which is not supported in App Engine. This answer to a different question provides a possible solution by changing marshal
to use pickle
methods. Has anyone tried this?
In general, is there anything else that I should take into consideration when using Jinja2 with App Engine?
Any help would be greatly appreciated!
Thanks.
Rodrigo Moraes created some special loaders for Jinja2 under GAE, see here. It's not bytecode caching but it precompiles all templates to Python so you avoid the Jinja2 parsing overhead.
Note that (from this GAE page):
compiled application code is cached for rapid responses to web requests
这篇关于Google App Engine中的Jinja2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!