On Čec. 21, 2014, 8:33 odp., Miloslav Trmac wrote:
config/roles/testrole/role.py, lines 109-116 http://reviewboard-fedoraserver.rhcloud.com/r/17/diff/1/?file=91#file91line109
Silently returns None on an unmatched property
Thomas Woerner wrote: get_property is not needed if the setting is in _DEFAULTS, see RoleBase.get_property:
if hasattr(x, "_settings") and prop in x._settings: return x._settings[prop] ... elif prop in x._DEFAULTS: return x._DEFAULTS[prop] Therefore settings in _settings and in _DEFAULTS are already taken care of. This means get_property should not be needed in a Role.
The concern is about completely unknown setting names; the final do_get_property() just returns None for them.
On Čec. 21, 2014, 8:33 odp., Miloslav Trmac wrote:
src/rolekit/server/rolebase.py, line 165 http://reviewboard-fedoraserver.rhcloud.com/r/17/diff/1/?file=92#file92line165
1. Because the method returns None, this doesn’t fire. 2. Blind “except:” is evil. Either define a specific exception type for this, or at the very least an unique object: PropertyNotRecognizedValue = object(); globally, then v = x.do_get_property(…) if v is not PropertyNotRecognizedValue: return v
Miloslav Trmac wrote: (Or is there a guarantee that None can never be a valid property value? If so, None could be used instead of PropertyNotRecognizedValue.)
Thomas Woerner wrote: None is not accepted by dbus.
OK, but the code still doesn’t work as written because it just tries to return None and UNKNOWN_SETTING is never returned.
- Miloslav
----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: http://reviewboard-fedoraserver.rhcloud.com/r/17/#review57 -----------------------------------------------------------
On Čec. 22, 2014, 5:35 odp., Thomas Woerner wrote:
This is an automatically generated e-mail. To reply, visit: http://reviewboard-fedoraserver.rhcloud.com/r/17/
(Updated Čec. 22, 2014, 5:35 odp.)
Review request for RoleKit Mailing List, Stephen Gallagher and Thomas Woerner.
Repository: rolekit
Description
Simplifies the role interface Role cleanup by dropping "failonthis" setting
Diffs
config/roles/testrole/role.py 2f077c62b4a8027e7783a2e08c84bc9c9715393e src/rolekit/server/rolebase.py 50b5685a038789d02d3f3b0451f5edaecc187964
Diff: http://reviewboard-fedoraserver.rhcloud.com/r/17/diff/
Testing
Thanks,
Thomas Woerner