[Checkins] SVN: z3c.recipe.ldap/trunk/z3c/recipe/ldap/ Finish the
slapadd recipe
Ross Patterson
me at rpatterson.net
Sun Dec 9 09:18:45 EST 2007
Log message for revision 82211:
Finish the slapadd recipe
Changed:
U z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt
U z3c.recipe.ldap/trunk/z3c/recipe/ldap/slapadd.py
-=-
Modified: z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt
===================================================================
--- z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt 2007-12-09 13:55:29 UTC (rev 82210)
+++ z3c.recipe.ldap/trunk/z3c/recipe/ldap/docs/README.txt 2007-12-09 14:18:45 UTC (rev 82211)
@@ -168,9 +168,12 @@
Initalizing an LDAP database
----------------------------
-In the simplest form, simply provide an ldif arguemnt in the part with
-one or more filenames.
+The z3c.recipe.ldap.Slapadd can be used initialize an LDAP database
+from an LDIF file. In the simplest form, simply provide an "ldif"
+option in the part with one or more filenames.
+Write some LDIF files::
+
>>> write(sample_buildout, 'foo.ldif',
... """
... olcAttributeTypes: ( 0.9.2342.19200300.100.1.25
@@ -180,7 +183,10 @@
... SUBSTR caseIgnoreIA5SubstringsMatch
... SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
... """)
+ >>> write(sample_buildout, 'bar.ldif', '\n')
+Write a buildout.cfg that lists those files::
+
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
@@ -195,20 +201,23 @@
... [slapadd]
... recipe = z3c.recipe.ldap:slapadd
... conf = ${slapd:conf}
- ... ldif = foo.ldif
+ ... ldif =
+ ... foo.ldif
+ ... bar.ldif
... """)
+Running the buildout adds the LDIF files to the LDAP database::
+
>>> print system(buildout),
Uninstalling slapd.
Installing slapd.
Generated script '/sample-buildout/bin/slapd'.
Installing slapadd.
+ bdb_db_open:...
-Multiple LDIF files can be specified::
+The LDIF files are added on update also::
- >>> TODO
-
-An alternate open ldap instance directory can be specified in the
-'directory' option::
-
- >>> TODO
\ No newline at end of file
+ >>> print system(buildout),
+ Updating slapd.
+ Updating slapadd.
+ bdb_db_open:...
Modified: z3c.recipe.ldap/trunk/z3c/recipe/ldap/slapadd.py
===================================================================
--- z3c.recipe.ldap/trunk/z3c/recipe/ldap/slapadd.py 2007-12-09 13:55:29 UTC (rev 82210)
+++ z3c.recipe.ldap/trunk/z3c/recipe/ldap/slapadd.py 2007-12-09 14:18:45 UTC (rev 82211)
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Recipe slapadd"""
-import os
+import os, subprocess
class Slapadd(object):
"""This recipe is used by zc.buildout"""
@@ -9,29 +9,28 @@
def __init__(self, buildout, name, options):
self.name, self.options = name, options
+ options['conf'] = os.path.join(
+ buildout['buildout']['directory'], options['conf'])
+
+ if 'slapadd' in options:
+ options['slapadd'] = os.path.join(
+ buildout['buildout']['directory'], options['slapadd'])
+ else:
+ options['slapadd'] = 'slapadd'
+
self.ldifs = [
os.path.join(buildout['buildout']['directory'],
ldif.strip())
for ldif in options['ldif'].split('\n') if ldif.strip()]
options['ldif'] = '\n'.join(self.ldifs)
- var = options.get('var')
- if var is None:
- self.var = options['var'] = os.path.join(
- buildout['buildout']['directory'],
- 'var', self.name)
- else:
- self.var = options['var'] = os.path.join(
- buildout['buildout']['directory'], var)
-
def install(self):
"""installer"""
- if not os.path.exists(self.var):
- os.mkdir(self.var)
-
- return tuple()
+ args = [self.options['slapadd'], '-f', self.options['conf']]
+ subprocess.Popen(args).wait()
+ return ()
def update(self):
"""updater"""
- pass
+ return self.install()
More information about the Checkins
mailing list