From: Michael <mi...@st...> - 2001-02-06 14:05:48
|
HI! For those of you who are interested in designing/implementing a new class API for python-ldap 2.0 the new Internet Draft "The Java LDAP Application Program Interface" http://www.ietf.org/internet-drafts/draft-ietf-ldapext-ldap-java-api-13.txt might be interesting. It looks more suitable for Python than going with the C-oriented LDAPEXT-API. Anyone interested in implementing that? Ciao, Michael. |
From: David L. <dav...@cs...> - 2001-02-07 00:02:51
|
On Tue, 6 Feb 2001, Michael Str=F6der typed thusly: > For those of you who are interested in designing/implementing a new > class API for python-ldap 2.0 the new Internet Draft > > "The Java LDAP Application Program Interface" > > http://www.ietf.org/internet-drafts/draft-ietf-ldapext-ldap-java-api-13.t= xt > > might be interesting. It looks more suitable for Python than going > with the C-oriented LDAPEXT-API. Anyone interested in implementing > that? well it looks nice. has anyone got any favourite bits? i like the decent methods on LDAPConnection. I think that if we take the java api, and convert all the Javaisms to Pythonisms we could even submit "our own" RFC draft. :) A lot in that java api is 'over the top' in terms of object-orientedness. Here are some: =09* do we really need a LDAPDN class? Isn't python's string enough? =09 (same with LDAPUrl - could be done in the urllib style) =09* AttributeSet is just a list =09* can we ignore/hide LDAPExtendedOperation/Response/Listener? the java api looks overly complex. after whittling it back a bit, i think a nice pythonesqe api could be developed. Here's some of the examples converted from Java to API #-- Example 9.1 import LDAP ld =3D LDAP.Connection() try: =09ld.connect("localhost", 389) =09ld.bind("", "") =09MY_FILTER =3D "sn=3DJensen" =09MY_SEARCHBASE =3D "o=3DAce Industry, c=3DUS" =09cons =3D ld.getSearchConstraints() =09cons.setBatchSize(1) =09res =3D ld.search(MY_SEARCHBASE, ld.SCOPE_ONE, MY_FILTER, None, 0, cons) =09for findEntry in res: =09=09print findEntry.getDN() =09=09findAttrs =3D findEntry.getAttributeSet() =09=09enumAttrs =3D findAttrs.getAttributes() =09=09print "Attributes:" =09=09for anAttr in enumAttrs: =09=09=09print `anAttr.getName()` =09=09=09for aVal in anAttr.getStringValues() =09=09=09=09print `aVal` except LDAP.Exception: =09print "Error!" if ld.isConnected(): =09ld.disconnect() #-- example 9.2 import LDAP ld =3D LDAP.Connection() try: =09MY_HOST =3D "localhost" =09MY_PORT =3D 389 =09ld.connect(MY_HOST, MY_PORT) =09MY_NAME =3D "cn=3DBarbara Jensen,o=3DAce Industry,c=3DUS" =09MY_PASSWORD =3D "MysteryLady" =09ld.bind(MY_NAME, MY_PASSWORD) =09attrEmail =3D LDAP.Attribute("mail", "ba...@ac...") =09mod =3D LDAP.Modification(LDAP.REPLACE, attrEmail) =09ld.modify(MY_NAME, mod) =09print "Entry modified" except LDAP.Exception: =09print "Error!" if ld.isConnected(): =09ld.disconnect() Feel free to convert some more to see if you like the feel of it, or if it reminds you of a way that its done in another python builtin/library. d --=20 David Leonard Dav...@ds... CRC For Distributed Systems Technology Room:78-632 Ph:+61 7 336 58358 The University of Queensland http://www.dstc.edu.au/ QLD 4072 AUSTRALIA B73CD65FBEF4C089B79A8EBADF1A932F13E= A0FC8 |
From: Federico Di G. <fo...@mi...> - 2001-02-07 00:14:21
|
i still doesn't have looked at the java api, but converting your examples to use my python classes is just a question of changing method names. ok, i'll look into the java api and see if i can convert my classes to respect the api. ciao, federico Scavenging the mail folder uncovered David Leonard's letter: > On Tue, 6 Feb 2001, Michael Ströder typed thusly: > > > For those of you who are interested in designing/implementing a new > > class API for python-ldap 2.0 the new Internet Draft > > > > "The Java LDAP Application Program Interface" > > > > http://www.ietf.org/internet-drafts/draft-ietf-ldapext-ldap-java-api-13.txt > > > > might be interesting. It looks more suitable for Python than going > > with the C-oriented LDAPEXT-API. Anyone interested in implementing > > that? > > well it looks nice. has anyone got any favourite bits? > i like the decent methods on LDAPConnection. > > I think that if we take the java api, and convert all the Javaisms > to Pythonisms we could even submit "our own" RFC draft. :) > > A lot in that java api is 'over the top' in terms of object-orientedness. > Here are some: > * do we really need a LDAPDN class? Isn't python's string enough? > (same with LDAPUrl - could be done in the urllib style) > * AttributeSet is just a list > * can we ignore/hide LDAPExtendedOperation/Response/Listener? > > the java api looks overly complex. after whittling it back a bit, i think > a nice pythonesqe api could be developed. > > Here's some of the examples converted from Java to API > > #-- Example 9.1 > import LDAP > ld = LDAP.Connection() > try: > ld.connect("localhost", 389) > ld.bind("", "") > MY_FILTER = "sn=Jensen" > MY_SEARCHBASE = "o=Ace Industry, c=US" > cons = ld.getSearchConstraints() > cons.setBatchSize(1) > res = ld.search(MY_SEARCHBASE, ld.SCOPE_ONE, MY_FILTER, None, 0, cons) > for findEntry in res: > print findEntry.getDN() > findAttrs = findEntry.getAttributeSet() > enumAttrs = findAttrs.getAttributes() > print "Attributes:" > for anAttr in enumAttrs: > print `anAttr.getName()` > for aVal in anAttr.getStringValues() > print `aVal` > except LDAP.Exception: > print "Error!" > if ld.isConnected(): > ld.disconnect() > > > #-- example 9.2 > import LDAP > > ld = LDAP.Connection() > try: > MY_HOST = "localhost" > MY_PORT = 389 > ld.connect(MY_HOST, MY_PORT) > > MY_NAME = "cn=Barbara Jensen,o=Ace Industry,c=US" > MY_PASSWORD = "MysteryLady" > ld.bind(MY_NAME, MY_PASSWORD) > > attrEmail = LDAP.Attribute("mail", "ba...@ac...") > mod = LDAP.Modification(LDAP.REPLACE, attrEmail) > ld.modify(MY_NAME, mod) > print "Entry modified" > except LDAP.Exception: > print "Error!" > if ld.isConnected(): > ld.disconnect() > > Feel free to convert some more to see if you like the feel of it, or > if it reminds you of a way that its done in another python builtin/library. > > d > -- > David Leonard Dav...@ds... > CRC For Distributed Systems Technology Room:78-632 Ph:+61 7 336 58358 > The University of Queensland http://www.dstc.edu.au/ > QLD 4072 AUSTRALIA B73CD65FBEF4C089B79A8EBADF1A932F13EA0FC8 > > > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > http://lists.sourceforge.net/lists/listinfo/python-ldap-dev -- Federico Di Gregorio MIXAD LIVE Chief of Research & Technology fo...@mi... Debian GNU/Linux Developer & Italian Press Contact fo...@de... Qu'est ce que la folie? Juste un sentiment de liberté si fort qu'on en oublie ce qui nous rattache au monde... -- J. de Loctra |
From: <520...@t-...> - 2001-02-07 09:39:02
|
Federico Di Gregorio wrote: > > i still doesn't have looked at the java api, but converting your examples > to use my python classes is just a question of changing method names. > ok, i'll look into the java api and see if i can convert my classes to > respect the api. I would prefer to stick to a class API which has been discussed on the LDAPEXT list quite thoroughly. It might also be more convenient for people working in the Python and Java world to find a similar API. Ciao, Michael. |
From: Federico Di G. <fo...@mi...> - 2001-02-07 09:45:51
|
Scavenging the mail folder uncovered Michael Str?der's letter: > Federico Di Gregorio wrote: > > > > i still doesn't have looked at the java api, but converting your examples > > to use my python classes is just a question of changing method names. > > ok, i'll look into the java api and see if i can convert my classes to > > respect the api. > > I would prefer to stick to a class API which has been discussed on > the LDAPEXT list quite thoroughly. It might also be more convenient > for people working in the Python and Java world to find a similar > API. maybe i din't express myself right. i wanted to say that, having already done part of the work in my classes, i'll look into the API and try to produce a working version of it borrowing from my (old) code. ciao, federico -- Federico Di Gregorio MIXAD LIVE Chief of Research & Technology fo...@mi... Debian GNU/Linux Developer & Italian Press Contact fo...@de... All programmers are optimists. -- Frederick P. Brooks, Jr. |
From: <520...@t-...> - 2001-02-07 10:16:25
|
David Leonard wrote: > = > On Tue, 6 Feb 2001, Michael Str=F6der typed thusly: > = > > http://www.ietf.org/internet-drafts/draft-ietf-ldapext-ldap-java-api-= 13.txt > > > > might be interesting. It looks more suitable for Python than going > > with the C-oriented LDAPEXT-API. Anyone interested in implementing > > that? > > I think that if we take the java api, and convert all the Javaisms > to Pythonisms we could even submit "our own" RFC draft. :) You're keen on having your name on top of a RFC? Well, why not... ;-) > * do we really need a LDAPDN class? Isn't python's string enoug= h? Well, the string representation of DNs according to RFC2253 is somewhat limited. A DN is something like: RelativeDistinguishedName ::=3D SET SIZE (1..MAX) OF AttributeTypeAndValue AttributeTypeAndValue ::=3D SEQUENCE { type AttributeType, value AttributeValue } AttributeValue can actually be any type. If e.g. a T61String is used and you convert it to a UTF-8-encoded string representation there's an information loss (the information about the original encoding). I'm not sure whether this affects handling DNs in LDAP but it affects handling DNs of certificate (in PKIX you might have to hash the DER-encoding of a DN e.g. in OCSP queries). I already have some code for a generic X.500 name class (for parsing certificates). It's not ready for prime time yet but I would like to improve it and contribute it to python-ldap. > (same with LDAPUrl - could be done in the urllib style) I think it's necessary to have distinguished classes. Because there are no method signatures in Python we have to distinguish the type of parameters in many class methods. Doing e.g. something like isinstance(param,LDAPURL) or other Pythonism like checking param.__class__.__name__ elps in this regard. > * AttributeSet is just a list No. ASN.1 type SET is a set which isn't a list. A set has no particular order. Believe me, you will need it. E.g. think about comparing to instances of AttributeSet... > * can we ignore/hide LDAPExtendedOperation/Response/Listener? > = > the java api looks overly complex. after whittling it back a bit, i thi= nk > a nice pythonesqe api could be developed. If X.500-based standards are involved things will always get complex. :-( Especially from my experience with parsing X.509 certs/CRLs I would strongly argue to stay as close as possible to this I-D. In the long run it's less work than repairing a limited subset afterwards. Off course some classes like LDAPExtendedOperation can be deferred...(though interesting for server-side sorting, virtual list controls etc.) Ciao, Michael. |
From: David L. <dav...@cs...> - 2001-02-07 23:35:46
|
more on the mapping of the java api to python (which it seems is a good thing) what I forgot to say in my previous message was that I wanted to encourage you (readers of this list) to attempt to convert some of the I-D examples into python as an exercise that might reveal what Java idioms have been used that make it incompatible (or uncomfortable to use) with Python. Java's Iterator and Python's 'for' construct are good examples where they are interchangable in many situations - but not all. only by attempting some expressions do you find out how clumsy/elegant/robust/error-prone they are. remember, by adding a library we are effectively extending a language. With a little work, future expressions in this language extension will be natural and effortless to its users. d On Wed, 7 Feb 2001, David Leonard typed thusly: > Here's some of the examples converted from Java to API > > #-- Example 9.1 > import LDAP > ld = LDAP.Connection() > try: > ld.connect("localhost", 389) > ld.bind("", "") > MY_FILTER = "sn=Jensen" > MY_SEARCHBASE = "o=Ace Industry, c=US" > cons = ld.getSearchConstraints() > cons.setBatchSize(1) > res = ld.search(MY_SEARCHBASE, ld.SCOPE_ONE, MY_FILTER, None, 0, cons) > for findEntry in res: > print findEntry.getDN() > findAttrs = findEntry.getAttributeSet() > enumAttrs = findAttrs.getAttributes() > print "Attributes:" > for anAttr in enumAttrs: > print `anAttr.getName()` > for aVal in anAttr.getStringValues() > print `aVal` > except LDAP.Exception: > print "Error!" > if ld.isConnected(): > ld.disconnect() > > > #-- example 9.2 > import LDAP > > ld = LDAP.Connection() > try: > MY_HOST = "localhost" > MY_PORT = 389 > ld.connect(MY_HOST, MY_PORT) > > MY_NAME = "cn=Barbara Jensen,o=Ace Industry,c=US" > MY_PASSWORD = "MysteryLady" > ld.bind(MY_NAME, MY_PASSWORD) > > attrEmail = LDAP.Attribute("mail", "ba...@ac...") > mod = LDAP.Modification(LDAP.REPLACE, attrEmail) > ld.modify(MY_NAME, mod) > print "Entry modified" > except LDAP.Exception: > print "Error!" > if ld.isConnected(): > ld.disconnect() > > Feel free to convert some more to see if you like the feel of it, or > if it reminds you of a way that its done in another python builtin/library. > > d > -- David Leonard Dav...@cs... Dept of Comp. Sci. and Elec. Engg _ Room:78-640 Ph:+61 7 336 51187 The University of Queensland |+| http://www.csee.uq.edu.au/~leonard/ QLD 4072 AUSTRALIA ~` '~ B73CD65FBEF4C089B79A8EBADF1A932F13EA0FC8 |