[python-ldap] O/R mapper
flo at chaoflow.net
Wed Apr 27 05:49:13 CEST 2011
On Fri, 22 Apr 2011 17:15:25 +0200, Michael Ströder <michael at stroeder.com> wrote:
> Florian Friesdorf wrote:
> > For me it looks like the attribute conversions could be handled by
> > subclassing and overwriting _ldap_call , in pseudo-code:
> > def _ldap_call(self, func, *args, **kwargs):
> > args = deep_utf8_copy(args)
> > kwargs = deep_utf8_copy(kwargs)
> > res = super(...)...
> > if not self.convmap:
> > return res
> > return check_for_things_to_convert(res, self.convmap)
> http://www.freeipa.org is doing something like this AFAICT with decorators.
> Check their code.
> But as repeated on this mailing list several times: In general this won't work
> without having knowledge of the subschema. E.g. your automatic conversion
> won't work for attributes like jpegPhoto, userCertificate, userPKCS12 etc.
> > Attribute conversion maps could be generated from automatically parsing
> > an ldap's schemas (if supported) or be provided by the user.
For fields were automatic conversion does not work, a conversion needs
to be specified by the user of the library. Nevertheless, I think the
place were the conversion is supposed to happen, is inside of
python-ldap, because otherwise people will keep reinventing that
> So you could have a look how web2ldap deals with all that based on
> schema-aware classes. Basically there are classes for each LDAP syntax
> registered by syntax OID with several possibilities to override that for
> certain attribute types. web2ldap itself is only interested in (Unicode)
> strings. One could extend the concept to convert to native Python data types.
Thank you for the pointer, will definitely have a look at it.
Why do you keep this functionality in web2ldap and not in python-ldap?
Florian Friesdorf <flo at chaoflow.net>
GPG FPR: 7A13 5EEE 1421 9FC2 108D BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo at chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 835 bytes
Desc: not available
More information about the python-ldap