aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bug.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-25 07:45:57 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-25 07:45:57 -0400
commit797bf225ff29a73fa0770d6cefef12a27cc3d760 (patch)
treeeb9d40593427525b6ee6f9189c36a35362cb61ce /libbe/bug.py
parent269778a3983bc56b02c921a306b257b18fe16c47 (diff)
downloadbugseverywhere-797bf225ff29a73fa0770d6cefef12a27cc3d760.tar.gz
tag --remove now returns bug.settings["extra_strings"] to EMPTY.
extra_strings returns to a defaulting property from a cached/generator property, with the help of the new, mutable defaults. Lots of deepcopies avoid mutable default uncertainty too ;). And copy.deepcopy([]) should be pretty cheap. tag --remove had previously left settings["extra_strings"] as [], which polluted the bug's values file. Now the improved defaulting_property notices a return to the default [], and sets the internally stored value to EMPTY. I struggled with creating a more intuitive way to notice changes to extra_strings than the tmp = bug.extra_strings <work on tmp> bug.extra_strings = tmp but didn't have any luck. The problem seems to be that if you only hand out copies of your default, you don't have any pointers to what you handed out to check for changes. On the other hand, if you hand out your original default, any external changes will _change_ your original default. I suppose you could only hand out copies, but keep a list of all copies handed out, but that sounds like a disaster. Reassigning is easy enough.
Diffstat (limited to 'libbe/bug.py')
-rw-r--r--libbe/bug.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/libbe/bug.py b/libbe/bug.py
index 0f912cf..7418933 100644
--- a/libbe/bug.py
+++ b/libbe/bug.py
@@ -185,11 +185,11 @@ class Bug(settings_object.SavedSettingsObject):
fset=_set_time,
doc="An integer version of .time_string")
- def _extra_strings_generator(self):
- return []
def _extra_strings_check_fn(value):
"Require an iterable full of strings"
- if not hasattr(value, "__iter__"):
+ if value == settings_object.EMPTY:
+ return True
+ elif not hasattr(value, "__iter__"):
return False
for x in value:
if type(x) not in types.StringTypes:
@@ -200,7 +200,7 @@ class Bug(settings_object.SavedSettingsObject):
self._prop_save_settings(old, new)
@_versioned_property(name="extra_strings",
doc="Space for an array of extra strings. Useful for storing state for functionality implemented purely in becommands/<some_function>.py.",
- generator=_extra_strings_generator,
+ default=[],
check_fn=_extra_strings_check_fn,
change_hook=_extra_strings_change_hook,
mutable=True)