From: Alain S. <asp...@gm...> - 2007-05-24 13:32:12
|
On 5/24/07, Michael Str=F6der <mi...@st...> wrote: > > Alain Spineux wrote: > > > > On 5/24/07, Michael Str=F6der <mi...@st...> wrote: > >> > > And how about specials like '*' and '+' in attrlist? Thanks for showing me my ignorance. I was not knowing about * and + ! Easy, only named attributes will be converted! In this case maybe is it possible to use [ '*', u'givenName', u'sn' ] to convert only 'givenName' and 'sn' > > Ops, I forgot the asynchronous side of ldap, but the msgid make the lin= k > > between both > > the request and the result and a dictionary store in the ldapobject > > could store the > > unicode transcoding info used in the request. And then ldap.result(), > > could use these > > info to decode the value when user call it. > > Yes, you could do this. But IMO it's cumbersome. YES and I hope you will integrate my patch in your mainstream source code :-) > I'start writin a wrapper for search() and modify() now. > > > > I send you my results as soon a possible. > > I'm not too keen to incorporate Unicode patches in python-ldap's > low-level API... not low-level Here is my work on progress class UnicodeLDAPObject(LDAPObject): expiration_delay=3D300 def __init__(self, uri, **kwargs): LDAPObject.__init__(self, uri, **kwargs) self.unicode_decoder=3D{} self.unicode_decoder_expire=3D[] def search_ext(self,base,scope, **kwargs): # filterstr=3D'(objectClass=3D*)',attrlist=3DNone,attrsonly=3D0,serverctrls= =3DNone,clientctrls=3DNone,timeout=3D-1,sizelimit=3D0 # convert filter try: kwargs['filter']=3Dunicode2utf8(kwargs['filter']) except KeyError: pass # convert arglist and keep a copy of original values for later decoding try: attrlist=3Dkwargs['attrlist'] kwargs['attrlist']=3Dmap(unicode2utf8(kwargs['attrlist'])) except KeyError: attrlist=3DNone mesgid=3DLDAPObject.search_ext(self,base,scope, **kwargs) if attrlist: self.unicode_decoder[mesgid]=3Dattrlist self.unicode_decoder_expire.append((mesgid, datetime.datetime.now()+datetime.timedelta(seconds=3Dself.expiration_delay)= )) return mesgid def result3(self, **kwargs): # msgid=3D_ldap.RES_ANY,all=3D1,timeout=3DNone): rtype, rdata, rmsgid, decoded_serverctrls=3DLDAPObject.result3(self= , **kwargs) Alain -- Alain Spineux aspineux gmail com May the sources be with you |