From 708ad2e66528fe6b8c65d72a416a261c1ffd4cd0 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 20 Jan 2010 21:04:40 +0000 Subject: [PATCH] add a __contains__ method to the config class fix upgrading old configs when the key doesn't exist in the old config --- deluge/config.py | 3 +++ deluge/ui/web/server.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/deluge/config.py b/deluge/config.py index d2bd71b5a..5a6202d07 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -156,6 +156,9 @@ class Config(object): self.load() + def __contains__(self, item): + return item in self.__config + def __setitem__(self, key, value): """ See diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index 78d3f768a..677b0d959 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -463,7 +463,8 @@ class DelugeWeb(component.Component): # all the values across to the new config file, and then remove # it. 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 # them otherwise.