@@ -92,8 +92,9 @@ class Config(dict):
9292 """
9393
9494 def __init__ (self , root_path , defaults = None ):
95- dict . __init__ ( self , defaults or {})
95+ self . defaults = defaults or {}
9696 self .root_path = root_path
97+ super ().__init__ ({})
9798
9899 def from_envvar (self , variable_name , silent = False ):
99100 """Loads a configuration from an environment variable pointing to
@@ -269,6 +270,21 @@ def get_namespace(self, namespace, lowercase=True, trim_namespace=True):
269270 rv [key ] = v
270271 return rv
271272
273+ def __getitem__ (self , item ):
274+ try :
275+ value = super ().__getitem__ (item )
276+ except KeyError :
277+ value = None
278+ if value is not None :
279+ return value
280+ value = os .environ .get (item , None )
281+ if value is not None :
282+ return value
283+ return self .defaults .get (item )
284+
285+ def __getattr__ (self , item ):
286+ return self .__getitem__ (item )
287+
272288 def __repr__ (self ):
273289 return '<%s %s>' % (self .__class__ .__name__ , dict .__repr__ (self ))
274290
@@ -302,6 +318,7 @@ def __repr__(self):
302318 'REPLAY_STORAGE' : {'TYPE' : 'server' },
303319 'LANGUAGE_CODE' : 'zh' ,
304320 'SECURITY_MAX_IDLE_TIME' : 60 ,
321+ 'ASSET_LIST_PAGE_SIZE' : 'auto' ,
305322}
306323
307324config = Config (root_path , default_config )
0 commit comments