本文整理匯總了Python中django.conf.settings._wrapped方法的典型用法代碼示例。如果您正苦於以下問題:Python settings._wrapped方法的具體用法?Python settings._wrapped怎麽用?Python settings._wrapped使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.conf.settings
的用法示例。
在下文中一共展示了settings._wrapped方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: enable
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def enable(self):
# Keep this code at the beginning to leave the settings unchanged
# in case it raises an exception because INSTALLED_APPS is invalid.
if 'INSTALLED_APPS' in self.options:
try:
apps.set_installed_apps(self.options['INSTALLED_APPS'])
except Exception:
apps.unset_installed_apps()
raise
override = UserSettingsHolder(settings._wrapped)
for key, new_value in self.options.items():
setattr(override, key, new_value)
self.wrapped = settings._wrapped
settings._wrapped = override
for key, new_value in self.options.items():
setting_changed.send(sender=settings._wrapped.__class__,
setting=key, value=new_value, enter=True)
示例2: handle
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def handle(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default_settings = module_to_dict(global_settings)
output = []
for key in sorted(user_settings):
if key not in default_settings:
output.append("%s = %s ###" % (key, user_settings[key]))
elif user_settings[key] != default_settings[key]:
output.append("%s = %s" % (key, user_settings[key]))
elif options['all']:
output.append("### %s = %s" % (key, user_settings[key]))
return '\n'.join(output)
示例3: handle_noargs
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def handle_noargs(self, **options):
# Inspired by Postfix's "postconf -n".
from django.conf import settings, global_settings
# Because settings are imported lazily, we need to explicitly load them.
settings._setup()
user_settings = module_to_dict(settings._wrapped)
default_settings = module_to_dict(global_settings)
output = []
for key in sorted(user_settings.keys()):
if key not in default_settings:
output.append("%s = %s ###" % (key, user_settings[key]))
elif user_settings[key] != default_settings[key]:
output.append("%s = %s" % (key, user_settings[key]))
return '\n'.join(output)
示例4: render
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def render(self):
try:
with self.modify_settings: # pylint: disable=not-context-manager
return super().render()
finally:
# if this attribute is still set that means disabling settings override
# failed which leads to navbar showing bogus menu items, see
# https://github.com/kiwitcms/Kiwi/issues/991
# => try to restore the original unmodified settings, see
# django.test.utils.override_settings().disable()
#
# NOTE: the only way to reproduce this reliably ATM is by raising exception
# in .disable() before restoring the original settings although I can see
# the problem on tcms.kiwitcms.org after the last restart 1 week ago!
# Maybe the switch to CBV and this response class made #991 harder to
# reproduce. It was easier to reproduce in the past by triggering some kind
# of exception in the FBV which used modify_settings() !!!
if hasattr(self.modify_settings, 'wrapped'):
settings._wrapped = self.modify_settings.wrapped # pylint: disable=protected-access
del self.modify_settings.wrapped
示例5: local_settings_update
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def local_settings_update(self, changes):
"""Update local_settings.py with new content created according to the changes parameter.
The changes parameter should be a list generated by check_modules()"""
if not local_settings:
raise SystemError('Missing local_settings.py!')
logger.info('Creating new local_settings.py with following changes: %s', self._show_changes(changes))
target = inspect.getsourcefile(local_settings)
data = self._local_settings_new(changes)
backup = inspect.getsource(local_settings)
logger.warn('Updating %s', target)
self._save_file(target, data)
try:
reload_module(local_settings)
except ImportError as e:
logger.exception(e)
logger.warn('Restoring %s from backup', target)
self._save_file(target, backup)
else:
# Force reloading of django settings
settings._wrapped = empty
示例6: disable
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def disable(self):
if 'INSTALLED_APPS' in self.options:
apps.unset_installed_apps()
settings._wrapped = self.wrapped
del self.wrapped
for key in self.options:
new_value = getattr(settings, key, None)
setting_changed.send(sender=settings._wrapped.__class__,
setting=key, value=new_value, enter=False)
示例7: load_config
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def load_config(self):
self.notifiers = notifiers.init(vars(settings._wrapped))
self.whitelist = [
DjangoRule(**item)
for item in getattr(settings, 'NPLUSONE_WHITELIST', [])
]
示例8: enable
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def enable(self):
override = UserSettingsHolder(settings._wrapped)
for key, new_value in self.options.items():
setattr(override, key, new_value)
settings._wrapped = override
for key, new_value in self.options.items():
setting_changed.send(sender=settings._wrapped.__class__,
setting=key, value=new_value)
示例9: disable
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def disable(self):
settings._wrapped = self.wrapped
for key in self.options:
new_value = getattr(settings, key, None)
setting_changed.send(sender=settings._wrapped.__class__,
setting=key, value=new_value)
示例10: clean_django_settings
# 需要導入模塊: from django.conf import settings [as 別名]
# 或者: from django.conf.settings import _wrapped [as 別名]
def clean_django_settings():
"""Clean current django settings."""
from django.conf import settings as django_settings
del os.environ['DJANGO_SETTINGS_MODULE']
django_settings._wrapped = None