gpt4 book ai didi

python - 为 webapp2 组织我的配置变量

转载 作者:行者123 更新时间:2023-11-28 20:10:07 24 4
gpt4 key购买 nike

为简单起见,我认为我需要将其重写为一条语句

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'}

如果我使用多个文件和多个请求处理程序,我想知道把它放在哪里。我应该把它放在一个文件中然后导入到其他文件中吗?由于 session 代码是 secret 的,您对通过源代码管理处理它有何建议?要始终在提交到源代码管理之前或之后更改 secret ?

谢谢

最佳答案

只需将 'webapp2_extras.sessions' 添加到您的字典初始值设定项中:

config = {'webapp2_extras.jinja2': {'template_path': 'templates',
'filters': {
'timesince': filters.timesince,
'datetimeformat': filters.datetimeformat},
'environment_args': {'extensions': ['jinja2.ext.i18n']}},
'webapp2_extras.sessions': {'secret_key': 'my-secret-key'}}

不过,如果嵌套是显式的,这会更清楚:

config = {
'webapp2_extras.jinja2': {
'template_path': 'templates',
'filters': {
'timesince': filters.timesince,
'datetimeformat': filters.datetimeformat
},
'environment_args': {'extensions': ['jinja2.ext.i18n']},
},
'webapp2_extras.sessions': {'secret_key': 'my-secret-key'}
}

关于python - 为 webapp2 组织我的配置变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8785925/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com