aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/settings_object.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-11 07:13:17 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-11 07:13:17 -0400
commit4038e118782113b404f0995e3c919d6e58195c22 (patch)
treebc92b208bb304f64fb3b55f10535cc1de93651c8 /libbe/settings_object.py
parentf3d16a7f477e1470aeb4bf342888c082ee1b7d67 (diff)
downloadbugseverywhere-4038e118782113b404f0995e3c919d6e58195c22.tar.gz
Fixed versioned_property(default=None, generator=None) defaults.
Now the behavior conforms to the docstring: If both default and generator are None, then the property will be a defaulting property which defaults to None.
Diffstat (limited to 'libbe/settings_object.py')
-rw-r--r--libbe/settings_object.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/libbe/settings_object.py b/libbe/settings_object.py
index 7326d1b..d362bf9 100644
--- a/libbe/settings_object.py
+++ b/libbe/settings_object.py
@@ -125,7 +125,7 @@ def versioned_property(name, doc,
required_saved_properties.append(name)
def decorator(funcs):
fulldoc = doc
- if default != None:
+ if default != None or generator == None:
defaulting = defaulting_property(default=default, null=EMPTY,
default_mutable=mutable)
fulldoc += "\n\nThis property defaults to %s" % default
@@ -145,7 +145,7 @@ def versioned_property(name, doc,
settings = settings_property(name=name, null=UNPRIMED)
docp = doc_property(doc=fulldoc)
deco = hooked(primed(settings(docp(funcs))))
- if default != None:
+ if default != None or generator == None:
deco = defaulting(deco)
if generator != None:
deco = cached(deco)
@@ -235,7 +235,7 @@ class SavedSettingsObjectTests(unittest.TestCase):
# access missing setting
self.failUnless(t._settings_loaded == False, t._settings_loaded)
self.failUnless(len(t.settings) == 0, len(t.settings))
- self.failUnless(t.content_type == EMPTY, t.content_type)
+ self.failUnless(t.content_type == None, t.content_type)
# accessing t.content_type triggers the priming, which runs
# t._setup_saved_settings, which fills out t.settings with
# EMPTY data. t._settings_loaded is still false though, since
@@ -250,16 +250,16 @@ class SavedSettingsObjectTests(unittest.TestCase):
self.failUnless(t._settings_loaded == True, t._settings_loaded)
self.failUnless(t.settings["Content-type"] == EMPTY,
t.settings["Content-type"])
- self.failUnless(t.content_type == EMPTY, t.content_type)
+ self.failUnless(t.content_type == None, t.content_type)
self.failUnless(len(t.settings) == 1, len(t.settings))
self.failUnless(t.settings["Content-type"] == EMPTY,
t.settings["Content-type"])
# now we set a value
- t.content_type = None
- self.failUnless(t.settings["Content-type"] == None,
+ t.content_type = 5
+ self.failUnless(t.settings["Content-type"] == 5,
t.settings["Content-type"])
- self.failUnless(t.content_type == None, t.content_type)
- self.failUnless(t.settings["Content-type"] == None,
+ self.failUnless(t.content_type == 5, t.content_type)
+ self.failUnless(t.settings["Content-type"] == 5,
t.settings["Content-type"])
# now we set another value
t.content_type = "text/plain"
@@ -273,7 +273,7 @@ class SavedSettingsObjectTests(unittest.TestCase):
self.failUnless(t._settings_loaded == True, t._settings_loaded)
self.failUnless(t.settings["Content-type"] == EMPTY,
t.settings["Content-type"])
- self.failUnless(t.content_type == EMPTY, t.content_type)
+ self.failUnless(t.content_type == None, t.content_type)
self.failUnless(len(t.settings) == 1, len(t.settings))
self.failUnless(t.settings["Content-type"] == EMPTY,
t.settings["Content-type"])
@@ -376,7 +376,7 @@ class SavedSettingsObjectTests(unittest.TestCase):
t.load_settings()
self.failUnless(SAVES == [], SAVES)
self.failUnless(t._settings_loaded == True, t._settings_loaded)
- self.failUnless(t.list_type == EMPTY, t.list_type)
+ self.failUnless(t.list_type == None, t.list_type)
self.failUnless(SAVES == [
"'None' -> '<class 'libbe.settings_object.EMPTY'>'"
], SAVES)