本文整理匯總了Python中configurations.values.Value方法的典型用法代碼示例。如果您正苦於以下問題:Python values.Value方法的具體用法?Python values.Value怎麽用?Python values.Value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類configurations.values
的用法示例。
在下文中一共展示了values.Value方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RAVEN_CONFIG
# 需要導入模塊: from configurations import values [as 別名]
# 或者: from configurations.values import Value [as 別名]
def RAVEN_CONFIG(self):
version_path = os.path.join(Core.BASE_DIR, "version.json")
try:
with open(version_path) as f:
build_info = json.loads(f.read())
version = build_info.get("version")
except IOError:
version = None
return {
"dsn": values.URLValue(None, environ_name="RAVEN_CONFIG_DSN"),
"release": values.Value(version, environ_name="RAVEN_CONFIG_RELEASE"),
}
# statsd
示例2: post_setup
# 需要導入模塊: from configurations import values [as 別名]
# 或者: from configurations.values import Value [as 別名]
def post_setup(cls):
super().post_setup()
# in case we don't find these AWS config variables in the environment
# we load them from the .env file
for param in ("ACCESS_KEY_ID", "SECRET_ACCESS_KEY", "DEFAULT_REGION"):
if param not in os.environ:
os.environ[param] = values.Value(
default="", environ_name=param, environ_prefix="AWS"
)
示例3: post_setup
# 需要導入模塊: from configurations import values [as 別名]
# 或者: from configurations.values import Value [as 別名]
def post_setup(cls):
"""Check database setup after settings are loaded"""
# super(Base, cls).post_setup()
if cls.DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
# Force strict mode (MySQL only)
# https://stackoverflow.com/questions/23022858/force-strict-sql-mode-in-django
if 'OPTIONS' not in cls.DATABASES['default']:
cls.DATABASES['default']['OPTIONS'] = {}
cls.DATABASES['default']['OPTIONS']['sql_mode'] = 'traditional'
# TODO Check this to handle "Incorrect string value" db error
# cls.DATABASES['default']['OPTIONS']['charset'] = 'utf8mb4'
cls.DATABASE_MYSQL = True
else:
cls.DATABASE_MYSQL = False
# Disable cache
if cls.DEBUG and cls.CACHE_DISABLE:
cls.CACHES['default']['BACKEND'] = 'django.core.cache.backends.dummy.DummyCache'
# Overwrite log filename
log_file = values.Value(default=None, environ_name='LOG_FILE')
if 'handlers' in cls.LOGGING and 'logfile' in cls.LOGGING['handlers'] and log_file:
cls.LOGGING['handlers']['logfile']['filename'] = os.path.join(cls.BASE_DIR, 'logs', log_file)