Adjusted becommands/set to handle user_id properly.
authorW. Trevor King <wking@drexel.edu>
Tue, 25 Nov 2008 02:15:55 +0000 (21:15 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 25 Nov 2008 02:15:55 +0000 (21:15 -0500)
becommands/set.py
libbe/bugdir.py

index 0085f0fc11bd0ab2903882e7523cedf8b2f391dc..24011f0801eb3d3dd538bb23b66f290f6d9f0b7a 100644 (file)
@@ -46,8 +46,10 @@ def execute(args):
         print bd.settings.get(args[0])
     else:
         if args[1] != "none":
-            old_setting = bd.settings[args[0]]
+            old_setting = bd.settings.get(args[0])
             bd.settings[args[0]] = args[1]
+            if args[0] == "user_id":
+                bd.save_user_id()
             
             # attempt to get the new value
             bd.save()
index 7e4cf3ec0a82a75fcff29bfd806ecca4069a3c97..596922f99e0a6711051d4b152983ec0590f99acb 100644 (file)
@@ -74,6 +74,9 @@ def setting_property(name, valid=None, doc=None):
     
     def setter(self, value):
         if value != getter(self):
+            if valid is not None:
+                if value not in valid and value != None:
+                    raise InvalidValue(name, value)
             if value is None:
                 del self.settings[name]
             else:
@@ -178,7 +181,7 @@ settings easy.  Don't set this attribute.  Set .rcs instead, and
     rcs = property(_get_rcs, _set_rcs,
                    doc="A revision control system (RCS) instance")
 
-    _user_id = setting_property("user-id", doc=
+    _user_id = setting_property("user_id", doc=
 """The user's prefered name.  Kept seperate to make saving/loading
 settings easy.  Don't set this attribute.  Set .user_id instead,
 and ._user_id will be automatically adjusted.  This setting is
@@ -238,9 +241,9 @@ that the Arch RCS backend *enforces* ids with this format.""")
             self.settings = self._get_settings(self.get_path("settings"))
             
             self.rcs = rcs.rcs_by_name(self.rcs_name)
-            if self._user_id != None: # was a user name in the settings file
-                self.save_user_id()            
-            
+            if self.settings.get("user_id") != None:
+                self.save_user_id()  # was a user name in the settings file
+
         self._bug_map_gen()
 
     def load_all_bugs(self):
@@ -286,9 +289,9 @@ that the Arch RCS backend *enforces* ids with this format.""")
                 # to go cluttering up his file system with settings files.
                 return
             if self._save_user_id == False:
-                if "user-id" in settings:
+                if "user_id" in settings:
                     settings = copy.copy(settings)
-                    del settings["user-id"]
+                    del settings["user_id"]
         allow_no_rcs = not self.rcs.path_in_root(settings_path)
         # allow_no_rcs=True should only be for the special case of
         # configuring duplicate bugdir settings
@@ -304,7 +307,7 @@ that the Arch RCS backend *enforces* ids with this format.""")
         duplicate_settings = self._get_settings(duplicate_settings_path)
         if "rcs_name" in duplicate_settings:
             duplicate_settings["rcs_name"] = "None"
-            duplicate_settings["user-id"] = self.user_id
+            duplicate_settings["user_id"] = self.user_id
             self._save_settings(duplicate_settings_path, duplicate_settings)
 
         return BugDir(duplicate_path, from_disk=True)