Ed Leafe wrote:
> Log:
> Fixed an issue when setting the DataSource to a dPref object. Previously we
> were essentially checking for bool(self.DataSource), but when the DataSource
> is a dPref, it will always return False.
Ok, so now I understand why dPref always evaluates to a boolean False:
from dPref.py:
{{{
470 def __nonzero__(self):
471 """Preference instances should always evaluate to a boolean False,
472 as they represent a lack of a value; i.e., a dot-separated path, but
473 not an actual stored value."""
474 return False
}}}
But I don't understand the rationale for returning False instead of
corresponding to the value of the preference. If the stored pref is
int(0), return False. If it is tuple("apples", "bananas"), return True. Etc.
I guess I don't get the 'lack of value' argument. Pref objects store
values (or as the case may be, lacks of value). A dot-separated path is
a value, no?
Shouldn't __nonzero__ simply return bool(the_value)?
Now, back to the fix in r5448, because my proposition above would cause
a need to revisit it. What we should be testing for in dDataControlMixin
is whether or not self.DataSource is defined, not whether the object it
is set to returns a boolean True or not. So I think that changing those
to simply read:
if self.DataSource is not None
should be sufficient, and would keep similar problems from happening
with other non-dPref objects.
I'm happy to make these changes if they are agreeable. Thoughts?
Paul
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[email protected]