Re: Experiments with pyasn1 and preread control
Hello Andreas, I've added your demo script to python-ldap's CVS as Demo/pyasn1/prereadcontrol.py. I'd appreciate if you could implement the decodeControlValue() method with pyasn1. Ciao, Michael. Andreas Hasenack wrote: > I have been having fun with controls. Today I tried to use the Pre-Read > control together with the modify+increment extension, so that > modify+increment becomes actually useful. > > I first added the encoding part to the ldap.so module, but later got a > response from the pyasn1 mailing list and tried again in pure python. > The result is attached. It's not complete yet, just a test. > > The script uses mod_increment to increment uidNumber and gidNumber by > one. Attached to the modify operation is the preread control, so the > response includes the value prior to the modification. > > Here is the output of two consecutive runs. Both attributes started at > 1000 in LDAP: > > $ ./preread-asn1.py > res: (103, [], 2, > [PreReadControl(1.3.6.1.1.13.1,1.3.6.1.1.13.1,'0M\x04\x1fcn=unixIdPool,dc=example,dc=com0*0\x13\x04\tgidNumber1\x06\x04\x041\x13\x04\tuidNumber1\x06\x04\x041000')]) > $ ./preread-asn1.py > res: (103, [], 2, > [PreReadControl(1.3.6.1.1.13.1,1.3.6.1.1.13.1,'0M\x04\x1fcn=unixIdPool,dc=example,dc=com0*0\x13\x04\tgidNumber1\x06\x04\x0410010\x13\x04\tuidNumber1\x06\x04\x041001')]) > > First one returns "1000", and the second one "1001" for both attributes. > Now it's at 1002. > > The decoding part will probably be more difficult... As the control > response is a SearchResultEntry which is a bit more complex to decode. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: unicode value
Alain, Alain Spineux wrote: > > When investigating about python and unicode, I read somewhere (in a PEP > I thing) that python functions should accept and manage unicode string > as well as normal string. Without knowing the PEP (reference?) I guess this affects functions which takes a string as an argument and process it directly returning a result. In context of python-ldap this would be directly applicable to the functions in modules ldap.dn and ldap.filter. The basic problem here is that for the sake of backward-compability to LDAPv2 the charset has to be passed around either. That's what I'm doing in web2ldap. > Of course if these strings could contains user > readable characters. Let's call that "textual strings". > Anyway I see 2 solutions > > 1. Let result() return non unicode strings. _HERE_ The user know all > returned > strings are normal strings utf-8 encoded and he can do the encoding > himself. A helper function doing the job for the result structure > should be welcome. > > 2. Do the conversion regarding the info provided in the query, as my > source sample does. > > I answer now some of your previous comment: > >> > In this case maybe is it possible to use [ '*', u'givenName', u'sn' ] >> > to convert only 'givenName' and 'sn' > >> But then you will not gain much! Still the application has to know which >> attributes have to be converted. => It's not worth hiding the conversion >> within python-ldap. > > I don't really hide the conversion, because the user has to request it using > unicode field name. I don't like this approach. The type of the attribute names is causing a type conversion side-effect. I don't consider this to be good design and I guess most Python developers would not expect something like this. Think about an application accidently passing in Unicode strings but is not really prepared to get the Unicode/string mix. > Do you really consider to add the schema processing for unicode > integration in the future? Nope. It's up to the application programmer, especially based on whether LDAPv2 support is still needed for a particular application or not. I consider python-ldap to be rather a low-level API. > Keep in mind, none of my code break compatibility with existing application. Generally I don't want to discourage people to work on something. But sorry, I won't add your code to python-ldap's Lib/. I hope you're not upset. My proposal would be to add it under Demo/ so you're work can be considered to be used by others. Or you can put it on your own web page (for further development) and I'll put a link to it on http://python-ldap.sourceforge.net/docs.shtml. Ciao, Michael. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Experiments with pyasn1 and preread control
On Thu, Jul 19, 2007 at 01:21:07PM +0200, Michael Ströder wrote: > Hello Andreas, > > I've added your demo script to python-ldap's CVS as > Demo/pyasn1/prereadcontrol.py. I'd appreciate if you could implement the > decodeControlValue() method with pyasn1. I think that would be more difficult, there are lots of classes that would need to be created, I guess almost the entire LDAP specification :) I'll try something with openldap's internal functions, but last time I hit a rock because I needed the connection object to do that, and it wasn't available. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
Re: Experiments with pyasn1 and preread control
Andreas Hasenack wrote: > On Thu, Jul 19, 2007 at 01:21:07PM +0200, Michael Ströder wrote: >> Hello Andreas, >> >> I've added your demo script to python-ldap's CVS as >> Demo/pyasn1/prereadcontrol.py. I'd appreciate if you could implement the >> decodeControlValue() method with pyasn1. > > I think that would be more difficult, there are lots of classes that > would need to be created, I guess almost the entire LDAP specification > :) Hmm...do you really think so? > I'll try something with openldap's internal functions, but last time I > hit a rock because I needed the connection object to do that, and it > wasn't available. I'd be interested to implement support for the post-read control in web2ldap because if you add/modify entries to OpenLDAP's back-config the DNs may be modified (due to X-ORDERED). Ciao, Michael. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
