samba4-ol-mmr

Michael Ströder michael at stroeder.com
Wed Aug 13 12:45:01 GMT 2008


Andrew Bartlett wrote:
> On Tue, 2008-08-12 at 15:31 +0200, Oliver Liebel wrote:
>> i didnt make use of the split-function yet, i will try that later.
> 
> OK.  Perhaps look at some of the other uses of arrays in python to
> figure out the best use.

Well, it's the .split() method you can use for any string. Note that 
this parsing could be made robust by handling double-spaces (filtering 
out empty values).

Python 2.5.2 (r252:60911, Jun  6 2008, 23:32:27)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> s='ldap://host1  ldapi:/// ldaps://host2'
 >>> s.split(' ')
['ldap://host1', '', 'ldapi:///', 'ldaps://host2']
 >>> filter(None,s.split(' '))
['ldap://host1', 'ldapi:///', 'ldaps://host2']
 >>>

The use of filter(None,l) strips out the null-values from the list l.

> For example, replace ${CONFIGDN} with ${MMRDN} and rid=3 with rid=
> ${RID1} and rid=${RID2}

I really wonder why this templating syntax is used instead of simply 
relying what Python provides. One could read in a template file and 
treat it like a Python string with dict-key formatters.

Python 2.5.2 (r252:60911, Jun  6 2008, 23:32:27)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> d={'key1':'value1','key2':'value2'}
 >>> 'Display 1. value "%(key1)s" and 2. value here "%(key2)s"' % (d)
'Display 1. value "value1" and 2. value here "value2"'

I make heavy use of it in web2ldap also for displaying template-based 
forms with input fields implemented by different Python plugin classes.

Ciao, Michael.


More information about the samba-technical mailing list