Mako 与 Google App Engine - 您如何处理临时文件?
我修改了我的 Google App Engine 应用程序以与 Mako 配合使用。为此,我遵循了这个答案,包括评论:
Mako templates with Google App Engine
然而,一旦你开始从文件加载模板,你就会遇到一个大问题。默认情况下,mako/template.py 中的 Mako 模板想要创建一个临时文件来存储编译后的模板。据我所知,GAE 不允许您创建临时文件。有没有人遇到过这个问题并找到解决方法?
I modified my Google App Engine app to work with Mako. To do this, I followed this answer including the comments:
Mako templates with Google App Engine
However, once you get to loading templates from files, you run into a big problem. By default, Mako's Template from mako/template.py wants to create a temporary file to store your compiled template. As far as I can tell, GAE doesn't allow you to create a temp file though. Has anyone run into this and figured out a work-around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编写 aha 框架的出色团队实际上已经解决了这一问题。这里的 mako_patch 函数使 Mako 将临时文件存储在内存缓存中而不是文件系统上: http://code.google.com/p/aha-gae/source/browse/aha/controller/makocontroller.py
编辑:作为@Nick Johnson点出,将其存储在本地内存中同样有意义,并且不会产生内存缓存的成本。
The awesome team that wrote the aha framework actually figured this out. The mako_patch function here makes Mako store temporary files in memcache instead of on the filesystem: http://code.google.com/p/aha-gae/source/browse/aha/controller/makocontroller.py
EDIT: as @Nick Johnson points out, storing this in local memory would make just as much sense and not incur the cost of memcache.