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


Python LazySettings.configure方法代碼示例

本文整理匯總了Python中django.conf.LazySettings.configure方法的典型用法代碼示例。如果您正苦於以下問題:Python LazySettings.configure方法的具體用法?Python LazySettings.configure怎麽用?Python LazySettings.configure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.conf.LazySettings的用法示例。


在下文中一共展示了LazySettings.configure方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_dict_setting_clear_defaults

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
    def test_dict_setting_clear_defaults(self):
        """
        Test the ability to deactivate the merge feature of dictionary settings.
        """
        s = LazySettings()
        s.configure(CACHES={
            '_clear_defaults': True,
            'temp': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}
        })
        self.assertDictEqual(s.CACHES, {
            '_clear_defaults': True,
            'temp': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}
        })

        # Also work on a subkey
        s = LazySettings()
        s.configure(CACHES={
            'default': {
                '_clear_defaults': True,
                'LOCATION': 'unique-snowflake',
            }
        })
        self.assertDictEqual(s.CACHES, {
            'default': {
                '_clear_defaults': True,
                'LOCATION': 'unique-snowflake',
            }
        })
開發者ID:2roy999,項目名稱:django,代碼行數:30,代碼來源:tests.py

示例2: test_dict_setting

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
    def test_dict_setting(self):
        """
        Test that dictionary-type settings can be "complemented", that is existing
        setting keys/values are not overriden by user settings, but merged into the
        existing dict.
        """
        s = LazySettings()  # Start with fresh settings from global_settings.py
        # Simply overwriting the key
        s.configure(CACHES={'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}})
        self.assertEqual(s.CACHES['default']['BACKEND'],
                         'django.core.cache.backends.dummy.DummyCache')

        s = LazySettings()
        # More complex overwriting
        s.configure(CACHES={
            'default': {'LOCATION': 'unique-snowflake'},
            'temp': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}
        })
        self.assertDictEqual(s.CACHES, {
            'default': {
                'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
                'LOCATION': 'unique-snowflake'
            },
            'temp': {
                'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
            }
        })
開發者ID:2roy999,項目名稱:django,代碼行數:29,代碼來源:tests.py

示例3: test_configure_initializes_logging

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
 def test_configure_initializes_logging(self):
     settings = LazySettings()
     settings.configure(
         LOGGING_CONFIG='regressiontests.logging_tests.tests.dictConfig')
     self.assertTrue(dictConfig.called)
開發者ID:Stunning,項目名稱:django,代碼行數:7,代碼來源:tests.py

示例4: test_configure

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
    def test_configure(self):
        s = LazySettings()
        s.configure(SECRET_KEY='foo')

        self.assertTrue(s.is_overridden('SECRET_KEY'))
開發者ID:ricardoffv,項目名稱:django-pizza,代碼行數:7,代碼來源:tests.py

示例5: test_usersettingsholder_repr

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
 def test_usersettingsholder_repr(self):
     lazy_settings = LazySettings()
     lazy_settings.configure(APPEND_SLASH=False)
     expected = '<UserSettingsHolder>'
     self.assertEqual(repr(lazy_settings._wrapped), expected)
開發者ID:DAWZayas-Projects,項目名稱:TEJEDOR-RETUERTO-ALEJANDRO,代碼行數:7,代碼來源:tests.py

示例6: test_nonupper_settings_ignored_in_default_settings

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
 def test_nonupper_settings_ignored_in_default_settings(self):
     s = LazySettings()
     s.configure(SimpleNamespace(foo='bar'))
     with self.assertRaises(AttributeError):
         getattr(s, 'foo')
開發者ID:EmadMokhtar,項目名稱:django,代碼行數:7,代碼來源:tests.py

示例7: test_nonupper_settings_prohibited_in_configure

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
 def test_nonupper_settings_prohibited_in_configure(self):
     s = LazySettings()
     with self.assertRaisesMessage(TypeError, "Setting 'foo' must be uppercase."):
         s.configure(foo='bar')
開發者ID:EmadMokhtar,項目名稱:django,代碼行數:6,代碼來源:tests.py

示例8: getattr

# 需要導入模塊: from django.conf import LazySettings [as 別名]
# 或者: from django.conf.LazySettings import configure [as 別名]
# -*- coding: utf-8 -*-

DJANGO_REQUEST_ENABLE_SETTING = 'DJANGO_REQUEST_ENABLE'
DJANGO_REQUEST_LOGFILE_SETTING = 'DJANGO_REQUEST_LOGFILE'
REQUEST_ID_HEADER_SETTING = 'DJANGO_REQUEST_LOG_REQUEST_ID_HEADER'
REQUEST_ID_RESPONSE_HEADER_SETTING = 'DJANGO_REQUEST_SET_REQUEST_ID_HEADER'
NO_REQUEST_ID = '-'

from django.conf import settings, LazySettings
from django_request_logger.log import LOGGING
import threading

__version__ = "0.1"

# ThreadLocal - dirty but does the job
local = threading.local()

if getattr(settings, DJANGO_REQUEST_ENABLE_SETTING, True):
    # override any existing logging configuration
    settings.LOGGING = LOGGING

    # create a new Settings object and pass in our settings,
    # we don't need/use the new Settings object, it is just to
    # get the private _configure_logging() method called
    unused_settings = LazySettings()
    unused_settings.configure(default_settings=settings)
開發者ID:eht16,項目名稱:django-request-logger,代碼行數:28,代碼來源:__init__.py


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