add getowner method

This commit is contained in:
gwen 2012-07-11 15:31:59 +02:00
parent 4ec7dff6c4
commit 736a1c77b6
2 changed files with 10 additions and 6 deletions

View File

@ -104,6 +104,7 @@ class Option(HiddenBaseType, DisabledBaseType, ModeBaseType):
return self.callback_params
def setowner(self, config, owner):
# config *must* be only the **parent** config (not the toplevel config)
# owner is a **real* owner, a list is actually allowable here
name = self._name
if self._frozen:
@ -118,6 +119,10 @@ class Option(HiddenBaseType, DisabledBaseType, ModeBaseType):
"option: {0}".format(self._name))
config._cfgimpl_value_owners[name] = owner
def getowner(self, config):
# config *must* be only the **parent** config (not the toplevel config)
return config._cfgimpl_owner[self._name]
def setoption(self, config, value, who):
"who is **not necessarily** a owner because it cannot be a list"
name = self._name

View File

@ -37,14 +37,13 @@ def test_attribute_access():
assert config.string == "foo"
def test_setitem():
s = StrOption("string", "", default=["string", None, "sdfsdf"], default_multi="prout", multi=True)
s = StrOption("string", "", default=["string", "sdfsdf"], default_multi="prout", multi=True)
descr = OptionDescription("options", "", [s])
config = Config(descr)
config._cfgimpl_values['string'].append("eggs")
# config.string = ["string"].append("eggs")
print config.string
# config.string[1] = "titi"
print config.string[1]
config.string[1] = "titi"
print config.string[1]
def test_reset():
"if value is None, resets to default owner"
s = StrOption("string", "", default="string")