Problem parsing LDIF change records
Roland Hedberg
roland.hedberg at adm.umu.se
Fri Sep 29 09:33:34 CEST 2006
Hi!
I'm having problem with LDIFParser and LDIF change records.
I'm using 2.2.0 which to my knowledge is the last official release.
The problematic line is line 382 in LDIFParser.parse(), the last one of
the following snippet.
elif attr_type=='changetype':
# attr type and value pair was DN of LDIF record
if dn is None:
raise ValueError, 'Read changetype: before getting valid dn:
line.'
if changetype!=None:
raise ValueError, 'Two lines starting with changetype: in
one record.'
if not valid_changetype_dict.has_key(attr_value):
raise ValueError, 'changetype value %s is invalid.' %
(repr(attr_value))
dn = attr_value
What happens here is that you replace the dn value, that you earlier has
picked up from the LDIF record, with the change type.
There is no easy way to figure out the dn later in the process and if
you like me really, really need the dn then you're lost.
So, to solve my problem, I've change the last line to:
changetype = attr_value
And then futher down the line
self.handle(dn,entry,changetype)
Which of course means I have to change the definition of handle to
def handle(self,dn,entry,changetype=None):
I get the impression from the code that this was the intention but then
somehow the coder got sidestepped :-)
-- Roland
More information about the python-ldap
mailing list