组织 webapp2 的配置变量
为简单起见,我认为我需要将其重写为一个语句
config = {'webapp2_extras.jinja2': {'template_path': 'templates',
'filters': {
'timesince': filters.timesince,
'datetimeformat': filters.datetimeformat},
'environment_args': {'extensions': ['jinja2.ext.i18n']}}}
config['webapp2_extras.sessions'] = \
{'secret_key': 'my-secret-key'}
然后我想知道如果我使用具有多个请求处理程序的多个文件将其放在哪里。我应该把它放在一个文件中然后导入到其他文件中吗?由于会话代码是秘密的,您对通过源代码控制处理它有什么建议?在提交源代码控制之前或之后始终更改秘密?
谢谢
For simplicity I think I need to rewrite this to just one statement
config = {'webapp2_extras.jinja2': {'template_path': 'templates',
'filters': {
'timesince': filters.timesince,
'datetimeformat': filters.datetimeformat},
'environment_args': {'extensions': ['jinja2.ext.i18n']}}}
config['webapp2_extras.sessions'] = \
{'secret_key': 'my-secret-key'}
Then I want to know where to put it if I use multiple files with multiple request handlers. Should I just put it in one file and import it to the others? Since the session code is secret, what are your recommendation for handling it via source control? To always change the secret before or after committing to source control?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将“webapp2_extras.sessions”添加到您的字典初始值设定项中即可:
不过,如果嵌套是显式的,这会更清晰:
Just add 'webapp2_extras.sessions' to your dict initializer:
This would be clearer if the nesting were explicit, though:
我建议将它们存储在数据存储实体中以获得更大的灵活性,并在启动时将它们缓存在实例内存中。
如果您想快速完成工作,您还可以考虑将 config.py 文件从源代码管理中排除。
I would recommend storing those in a datastore Entity for more flexibility and caching them in the instance memory at startup.
You could also consider having a
config.py
file excluded from the source control, if you want to get things done quickly.