add a __contains__ method to the config class

fix upgrading old configs when the key doesn't exist in the old config
This commit is contained in:
Damien Churchill 2010-01-20 21:04:40 +00:00
parent 0819697c5b
commit 708ad2e665
2 changed files with 5 additions and 1 deletions

View File

@ -156,6 +156,9 @@ class Config(object):
self.load() self.load()
def __contains__(self, item):
return item in self.__config
def __setitem__(self, key, value): def __setitem__(self, key, value):
""" """
See See

View File

@ -463,7 +463,8 @@ class DelugeWeb(component.Component):
# all the values across to the new config file, and then remove # all the values across to the new config file, and then remove
# it. # it.
for key in OLD_CONFIG_KEYS: for key in OLD_CONFIG_KEYS:
self.config[key] = old_config[key] if key in old_config:
self.config[key] = old_config[key]
# We need to base64 encode the passwords since json can't handle # We need to base64 encode the passwords since json can't handle
# them otherwise. # them otherwise.