Own pure Python parser for LDAPv3 schema support

Michael Ströder michael at stroeder.com
Wed Aug 14 18:47:26 CEST 2002


Jens Vagelpohl wrote:
 >> I hoped that someone bites the bullet and uses
 >> /usr/lib/python2.2/profile.py... ;-)
 >
 > hey, i told you i don't use python2.2 yet ;)

Hah, that's obviously no excuse... ;-)

 > i am noticing that the __init__ for ObjectClass, unlike all
 > others, does not just take the full schema_element_string, it
 > also takes all attributes as separate keyword arguments. that
 > seems a little redundant.

Python 2.2.1 (#2, May  4 2002, 19:50:26)
[GCC 2.95.3 20010315 (SuSE)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import ldap.schema
 >>>
str(ldap.schema.ObjectClass(oid='1.23.456.78.0',names=['myClass','myClassAlias'],must=['myRequiredAttr1','myRequiredAttr2'],may=['myAllowed1']))
"( 1.23.456.78.0 NAME ( 'myClass' 'myClassAlias' ) STRUCTURAL MUST
( myRequiredAttr1 $ myRequiredAttr2 ) MAY myAllowed1 )"
 >>>

Also works with Python 2.1.x! ;-)

Got the message? It's meant for automated schema element creation.
A schema editor comes to mind...

 > all other classes only take the schema_element_string and
 > extract the attributes from that.

Yes, they are not complete yet.

 > well, i would probably end up doing a widget that offers both a
 > dropdown and a text input field, maybe depending on errors
 > occurring during schema discovery.

Error handling is somewhat subtle.

Ciao, Michael.






More information about the python-ldap mailing list