can change expiration_time in api
This commit is contained in:
@ -23,14 +23,11 @@ from .error import (RequirementError, PropertiesOptionError,
|
||||
from .i18n import _
|
||||
|
||||
|
||||
"Default encoding for display a Config if raise UnicodeEncodeError"
|
||||
default_encoding = 'utf-8'
|
||||
|
||||
"""If cache and expire is enable, time before cache is expired.
|
||||
This delay start first time value/setting is set in cache, even if
|
||||
user access several time to value/setting
|
||||
"""
|
||||
expires_time = 5
|
||||
EXPIRATION_TIME = 5
|
||||
"""List of default properties (you can add new one if needed).
|
||||
|
||||
For common properties and personalise properties, if a propery is set for
|
||||
@ -68,7 +65,7 @@ cache
|
||||
if set, enable cache settings and values
|
||||
|
||||
expire
|
||||
if set, settings and values in cache expire after ``expires_time``
|
||||
if set, settings and values in cache expire after ``expiration_time``
|
||||
|
||||
everything_frozen
|
||||
whole option in config are frozen (even if option have not frozen
|
||||
@ -186,7 +183,9 @@ class ConfigBag:
|
||||
'properties', # properties for current context
|
||||
'true_properties', # properties for current context
|
||||
'permissives', # permissives for current context
|
||||
'expiration_time' # EXPIRATION_TIME
|
||||
)
|
||||
|
||||
def __init__(self, context, **kwargs):
|
||||
self.context = context
|
||||
for key, value in kwargs.items():
|
||||
@ -194,13 +193,18 @@ class ConfigBag:
|
||||
|
||||
def __getattr__(self, key):
|
||||
if key == 'properties':
|
||||
self.properties = self.context.cfgimpl_get_settings().get_context_properties()
|
||||
settings = self.context.cfgimpl_get_settings()
|
||||
self.properties = settings.get_context_properties()
|
||||
return self.properties
|
||||
if key == 'permissives':
|
||||
self.permissives = self.context.cfgimpl_get_settings().get_context_permissives()
|
||||
settings = self.context.cfgimpl_get_settings()
|
||||
self.permissives = settings.get_context_permissives()
|
||||
return self.permissives
|
||||
if key == 'true_properties':
|
||||
return self.properties
|
||||
if key == 'expiration_time':
|
||||
self.expiration_time = EXPIRATION_TIME
|
||||
return self.expiration_time
|
||||
raise KeyError('unknown key {} for ConfigBag'.format(key)) # pragma: no cover
|
||||
|
||||
def remove_warnings(self):
|
||||
@ -414,7 +418,7 @@ class Settings(object):
|
||||
if apply_requires:
|
||||
props = config_bag.properties
|
||||
is_cached, props = self._p_.getcache(path,
|
||||
expires_time,
|
||||
config_bag.expiration_time,
|
||||
index,
|
||||
props,
|
||||
{},
|
||||
|
Reference in New Issue
Block a user