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

Nathaniel McCallum npmccallum at redhat.com
Tue May 6 17:55:09 UTC 2014


I know it is a bit late on this, but for the OTP token import script, I
have to have support for the full ISO 8601. My plan right now is to use
python-dateutil for this.

Using dateutil would simplify some of this code. Is there a reason we
aren't using dateutil?

On Mon, 2014-05-05 at 18:58 +0300, Alexander Bokovoy wrote:
> 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.
> 





More information about the Freeipa-devel mailing list