[Freeipa-devel] Integer parameters

John Dennis jdennis at redhat.com
Mon Oct 19 14:24:27 UTC 2009


On 10/19/2009 09:12 AM, Pavel Zuna wrote:
> John Dennis wrote:
>> I wanted to assure myself if a command was expecting an integer value,
>> it could be input in whatever radix the user desires and be correctly
>> converted. If I understand correctly this code is in parameters.py and
>> is implemented by the _convert_scalar member function. The Int and
>> Float classes derive from the Number class and inherit
>> Number._convert_scalar which attempts to call the type (e.g.
>> constructor). However the int class only supports base 10 radix
>> strings in it's constructor, it will not do radix conversion.
>> Shouldn't the Int parameter class have it's own _convert_scalar which
>> invokes int(value, 0)? (Note: the second argument to the int
>> constructor is the radix base, with 0 being a special value indicating
>> the radix is to be derived from the prefix)
>>
> Int only accepts base 10. As you say, we could extend _convert_scalar
> and have it accept different bases. The question is, do we need/want it
> to? If we do, then it shouldn't be too hard to implement (and I
> volunteer to do it).

Thanks, but I've already made the code change and it will show up in a 
patch shortly. My main concern was this would alter the UI (accepting a 
radix other than base 10) and I wanted to make sure this did not occur 
without some discussion and/or awareness of the change.

My personal feeling is the desired behavior for our interfaces is:

* By default all integers are accepted as base 10 and presented in the 
UI as base 10.

* However to be friendly and to conform to some other external 
conventions, it should be possible to supply a value in hex and have the 
UI properly handle it. It's less clear to me whether the UI should ever 
present an integral value in hex even if there is some president for 
that particular value being presented in hex.

-- 
John Dennis <jdennis at redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/




More information about the Freeipa-devel mailing list