本文整理汇总了Python中core.model.ConfigurationSetting.sitewide_secret方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationSetting.sitewide_secret方法的具体用法?Python ConfigurationSetting.sitewide_secret怎么用?Python ConfigurationSetting.sitewide_secret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.model.ConfigurationSetting
的用法示例。
在下文中一共展示了ConfigurationSetting.sitewide_secret方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_do_run
# 需要导入模块: from core.model import ConfigurationSetting [as 别名]
# 或者: from core.model.ConfigurationSetting import sitewide_secret [as 别名]
def test_do_run(self):
# Normally, do_run is only called by run() if the database has
# not yet meen initialized. But we can test it by calling it
# directly.
timestamp = get_one(
self._db, Timestamp, service=u"Database Migration",
service_type=Timestamp.SCRIPT_TYPE
)
eq_(None, timestamp)
# Remove all secret keys, should they exist, before running the
# script.
secret_keys = self._db.query(ConfigurationSetting).filter(
ConfigurationSetting.key==Configuration.SECRET_KEY)
[self._db.delete(secret_key) for secret_key in secret_keys]
script = InstanceInitializationScript(_db=self._db)
script.do_run(ignore_search=True)
# It initializes the database.
timestamp = get_one(
self._db, Timestamp, service=u"Database Migration",
service_type=Timestamp.SCRIPT_TYPE
)
assert timestamp
# It creates a secret key.
eq_(1, secret_keys.count())
eq_(
secret_keys.one().value,
ConfigurationSetting.sitewide_secret(self._db, Configuration.SECRET_KEY)
)
示例2: setup_admin
# 需要导入模块: from core.model import ConfigurationSetting [as 别名]
# 或者: from core.model.ConfigurationSetting import sitewide_secret [as 别名]
def setup_admin(_db=None):
if getattr(app, 'manager', None) is not None:
setup_admin_controllers(app.manager)
_db = _db or app._db
# The secret key is used for signing cookies for admin login
app.secret_key = ConfigurationSetting.sitewide_secret(
_db, Configuration.SECRET_KEY
)