[Freeipa-devel] [PATCH 0137] ipalib: Add DateTime parameter
Alexander Bokovoy
abokovoy at redhat.com
Mon May 5 15:58:26 UTC 2014
On Wed, 30 Apr 2014, Tomas Babej wrote:
>
>On 04/25/2014 11:08 AM, Jan Cholasta wrote:
>> On 22.4.2014 13:32, Tomas Babej wrote:
>>> Thank you for the suggestions. Updated, rebased patch is attached.
>>>
>>
>> This API.txt change from the next patch belongs in this patch:
>>
>> +capability: datetime_values 2.84
>>
>>
>> I think you should use the LDAP_GENERALIZED_TIME_FORMAT constant here:
>>
>> + accepted_formats = ['%Y%m%d%H%M%SZ', # generalized time
>>
>>
>> This is not right:
>>
>> + elif isinstance(val, datetime.datetime):
>> + return val
>>
>> To actually decode LDAP generalized time attributes to datetime, you
>> need to do this:
>>
>> '2.16.840.1.113719.1.301.4.41.1' : DN, # krbSubTrees
>> '2.16.840.1.113719.1.301.4.52.1' : DN, # krbObjectReferences
>> '2.16.840.1.113719.1.301.4.53.1' : DN, # krbPrincContainerRef
>> +
>> + '1.3.6.1.4.1.1466.115.121.1.24' : datetime.datetime,
>> }
>>
>> # In most cases we lookup the syntax from the schema returned by
>>
>> and this:
>>
>> return val
>> elif target_type is unicode:
>> return val.decode('utf-8')
>> + elif target_type is datetime.datetime:
>> + return datetime.datetime.strptime(val,
>> LDAP_GENERALIZED_TIME_FORMAT)
>> else:
>> return target_type(val)
>> except Exception, e:
>>
>> and add code for formatting datetime values to the textui backend.
>>
>
>Thanks for the review. I fixed all the issues, updated patch is attached.
>
>I also added unit tests for the new DateTime parameter.
Thanks, tested them as part of kerberos principal expiration time
patches.
Pushed two patches to git master.
--
/ Alexander Bokovoy
More information about the Freeipa-devel
mailing list