[Freeipa-devel] [PATCH 0137] ipalib: Add DateTime parameter

Tomas Babej tbabej at redhat.com
Wed Apr 30 15:07:33 UTC 2014


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.

-- 
Tomas Babej
Associate Software Engineer | Red Hat | Identity Management
RHCE | Brno Site | IRC: tbabej | freeipa.org 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-tbabej-0137-7-ipalib-Add-DateTime-parameter.patch
Type: text/x-patch
Size: 12954 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20140430/2d05e34d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-tbabej-0183-ipatests-Cover-DateTime-in-test_parameters.py.patch
Type: text/x-patch
Size: 3545 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20140430/2d05e34d/attachment-0001.bin>


More information about the Freeipa-devel mailing list