當前位置: 首頁>>代碼示例>>Python>>正文


Python ConfigurationSetting.sitewide_secret方法代碼示例

本文整理匯總了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)
        )
開發者ID:NYPL-Simplified,項目名稱:circulation,代碼行數:34,代碼來源:test_scripts.py

示例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
    )
開發者ID:NYPL-Simplified,項目名稱:circulation,代碼行數:10,代碼來源:routes.py


注:本文中的core.model.ConfigurationSetting.sitewide_secret方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。