fix ...
Content-type: text/plain

Author: damoxc

Revision: 6103

Log:
        add a __contains__ method to the config class
fix upgrading old configs when the key doesn't exist in the old config

Diff:
Modified: branches/1.2_RC/deluge/config.py
===================================================================
--- branches/1.2_RC/deluge/config.py    2010-01-20 20:37:14 UTC (rev 6102)
+++ branches/1.2_RC/deluge/config.py    2010-01-20 21:04:40 UTC (rev 6103)
@@ -156,6 +156,9 @@
 
         self.load()
 
+    def __contains__(self, item):
+        return item in self.__config
+
     def __setitem__(self, key, value):
         """
         See

Modified: branches/1.2_RC/deluge/ui/web/server.py
===================================================================
--- branches/1.2_RC/deluge/ui/web/server.py     2010-01-20 20:37:14 UTC (rev 
6102)
+++ branches/1.2_RC/deluge/ui/web/server.py     2010-01-20 21:04:40 UTC (rev 
6103)
@@ -463,7 +463,8 @@
                 # 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.

Modified: trunk/deluge/config.py
===================================================================
--- trunk/deluge/config.py      2010-01-20 20:37:14 UTC (rev 6102)
+++ trunk/deluge/config.py      2010-01-20 21:04:40 UTC (rev 6103)
@@ -156,6 +156,9 @@
 
         self.load()
 
+    def __contains__(self, item):
+        return item in self.__config
+
     def __setitem__(self, key, value):
         """
         See

Modified: trunk/deluge/ui/web/server.py
===================================================================
--- trunk/deluge/ui/web/server.py       2010-01-20 20:37:14 UTC (rev 6102)
+++ trunk/deluge/ui/web/server.py       2010-01-20 21:04:40 UTC (rev 6103)
@@ -463,7 +463,8 @@
                 # 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.


-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.


Reply via email to