ANN: ldiftemplate 0.1.0 released
Tjabo Kloppenburg
tjabo.kloppenburg@unix-ag.org
Sat, 12 Oct 2002 11:05:52 +0200
--=.f+'YvTCz)+2QF)
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
NAME:
ldiftemplate - a small module for quick "boss can add ldap objects" scripts.
DESCRIPTION:
When you're really happy with your ldap tree the moment comes where a dumb
person (boss) asks you how he can hang new objects into this fancy tree
by himself... Ugly... :-)
This class gives me the ability to code simple scripts my boss can use to
add some objects. It uses LDIF templates derived from real objects -- with
simple placeholders in it.
The class gives you a list of placeholders and descriptions so it is easy
to print them before requesting the values (boss can see what he needs).
After doing setPlaceholder( key, val ) for every placeholder you simply call
getTupleList() to get a list with the two args you need for ldap.add_s().
It is fairly simple.
MISSING FEATURES:
- no support for base64 data ("name:: VALUE" in LDIF)
- no detection for cross placeholder replacing
[2 placeholders TTT and BUG: call setPlaceholder( 'TTT', 'HUMBUG') +
setPlaceholder('BUG','something'): --> 'TTT: HUMsomething']
HOMEPAGE:
http://www.home.unix-ag-org/tjabo/ldap/ (german)
The in-source docs are english. And there's a method ".sample()", printing
a sample LDIF template.
Yes, the class's name is "new". I did not want to type "ldiftemplate"
over and over again...
HINT:
Use placeholders with three or more BIG LETTERS!
EXAMPLES/DEMO:
I'll show how to add simple "customer" objects. They need cn and custID:
TEMPLATE (newCustomer.template):
#TITLE Quick new customer.
#DEF XXX Name of customer
#DEF YYY Customer id
dn: cn=XXX,ou=customers,o=company
objectClass: customer
objectClass: top
cn: XXX
custID: YYY
SCRIPT:
#!/usr/bin/env python2.2
import ldiftemplate
t = ldiftemplate.new( 'newCustomer.template' )
ph = t.getPlaceholders() # [ ('XXX', 'Name of customer'), ... ]
print t.title
print " I need: \n - " + "\n - ".join( map( lambda x: x[1], ph ) )
for p in ph:
e = raw_input( "%s> " % ( p[1] ) )
t.setPlaceholder( p[0], e )
print t.getTupleList()
OUTPUT:
Quick new customer.
I need:
- Name of customer
- Customer id
Name of customer> FlyLime Ltd
Customer id> 1034
('cn=FlyLime Ltd,ou=customers,o=company', [('objectClass', ['customer',
'top']), ('custID', ['1034']), ('cn', ['FlyLime Ltd'])])
The next step would be to do ldap.initialize(...), bind(...), and
l.add_s( L[0], L[1] ).
INSTALLATION:
Copy ldiftemplate.py to a good place. :-)
"/usr/lib/python2.2/site-packages/"
or
"<the directory where your program is>"
--
Tjabo Kloppenburg
GnuPG Key is on http://www.home.unix-ag.org/tjabo/kontakt.html
--=.f+'YvTCz)+2QF)
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
iD8DBQE9p+X1tGnpFGyUbjERArX4AKCDqLaV4scPnwJ+OitmdJSJoll0hACglYLo
LkTwmVDOfpkeoYU2grIuaF0=
=w7MV
-----END PGP SIGNATURE-----
--=.f+'YvTCz)+2QF)--