From: Guruprasad <lgp...@gm...> - 2009-05-16 12:29:41
|
Hi, I tried generating a LDIF file from a dictionary using 'ldif' module as illustrated in http://www.python-ldap.org/doc/html/ldif.html. But at the end of the LDIF data, I get a newline and a 'None', whereas there is no such thing in the result shown in that example. How to get rid of those unwanted characters. I am using Python-LDAP 2.3.5-1 on Debian Lenny. Thank you. Regards, Guruprasad. |
From: Michael S. <mi...@st...> - 2009-05-16 12:41:53
|
Guruprasad wrote: > Hi, > I tried generating a LDIF file from a dictionary using 'ldif' module > as illustrated in http://www.python-ldap.org/doc/html/ldif.html. But > at the end of the LDIF data, I get a newline and a 'None', whereas > there is no such thing in the result shown in that example. How to get > rid of those unwanted characters. I am using Python-LDAP 2.3.5-1 on > Debian Lenny. Could you please post your code (in a short form) demonstrating the issue? Note that there is a new-line after each entry record. But was 'None' is in your case is not clear to me. Ciao, Michael. |
From: Guruprasad <lgp...@gm...> - 2009-05-16 12:47:33
|
Hi, 2009/5/16 Michael Ströder <mi...@st...>: > Guruprasad wrote: >> Hi, >> I tried generating a LDIF file from a dictionary using 'ldif' module >> as illustrated in http://www.python-ldap.org/doc/html/ldif.html. But >> at the end of the LDIF data, I get a newline and a 'None', whereas >> there is no such thing in the result shown in that example. How to get >> rid of those unwanted characters. I am using Python-LDAP 2.3.5-1 on >> Debian Lenny. > > Could you please post your code (in a short form) demonstrating the > issue? Note that there is a new-line after each entry record. But was > 'None' is in your case is not clear to me. > Basically what I am trying to do with this code is that, I manipulate the result returned by ldapsearch to remove some attributes and generate a LDIF output for the modified entry. <code> res_type, result_data=l.result(res_id,0) if (result_data==[]): break dn=result_data[0][0] resd=result_data[0][1] resd["objectClass"].remove("inetLocalMailRecipient") resd["objectClass"].remove("organizationalPerson") resd["objectClass"].remove("inetOrgPerson") resd["objectClass"].remove("posixAccount") lw=ldif.LDIFWriter(sys.stdout) guru=lw.unparse(dn,resd) print guru </code> Is it some issue or am I making some mistakes with general usage of Python? Thank you. Regards, L.Guruprasad |
From: Guruprasad <lgp...@gm...> - 2009-05-16 12:51:41
|
2009/5/16 Guruprasad <lgp...@gm...>: > Hi, > > 2009/5/16 Michael Ströder <mi...@st...>: > <code> > res_type, result_data=l.result(res_id,0) > if (result_data==[]): > break > dn=result_data[0][0] > resd=result_data[0][1] > resd["objectClass"].remove("inetLocalMailRecipient") > resd["objectClass"].remove("organizationalPerson") > resd["objectClass"].remove("inetOrgPerson") > resd["objectClass"].remove("posixAccount") > lw=ldif.LDIFWriter(sys.stdout) > guru=lw.unparse(dn,resd) > print guru > </code> > > Is it some issue or am I making some mistakes with general usage of Python? > > Thank you. > > Regards, > L.Guruprasad > My ldapsearch query returns only one record. I have written such a filter. Regards, Guruprasad |
From: Michael S. <mi...@st...> - 2009-05-16 12:59:29
|
Guruprasad wrote: > My ldapsearch query returns only one record. I have written such a filter. Sorry, my crystal ball is a bit blurry. I can't help without really knowing what you're trying to achieve. Ciao, Michael. |
From: Michael S. <mi...@st...> - 2009-05-16 12:58:24
|
Guruprasad wrote: > 2009/5/16 Michael Ströder <mi...@st...>: >> Guruprasad wrote: >>> Hi, >>> I tried generating a LDIF file from a dictionary using 'ldif' module >>> as illustrated in http://www.python-ldap.org/doc/html/ldif.html. But >>> at the end of the LDIF data, I get a newline and a 'None', whereas >>> there is no such thing in the result shown in that example. How to get >>> rid of those unwanted characters. I am using Python-LDAP 2.3.5-1 on >>> Debian Lenny. >> Could you please post your code (in a short form) demonstrating the >> issue? Note that there is a new-line after each entry record. But was >> 'None' is in your case is not clear to me. >> > > Basically what I am trying to do with this code is that, I manipulate > the result returned by ldapsearch to remove some attributes and > generate a LDIF output for the modified entry. > > <code> > res_type, result_data=l.result(res_id,0) > if (result_data==[]): > break > dn=result_data[0][0] > resd=result_data[0][1] > resd["objectClass"].remove("inetLocalMailRecipient") > resd["objectClass"].remove("organizationalPerson") > resd["objectClass"].remove("inetOrgPerson") > resd["objectClass"].remove("posixAccount") > lw=ldif.LDIFWriter(sys.stdout) > guru=lw.unparse(dn,resd) > print guru > </code> Your code looks like processing of LDAP search results (because of the res_type). I'd recommend to look at the actual data in dictionary resd. Also note that the identiation seems wrong. This could be because of cut&paste to your MUA from the editor with different tab-interpretation. But make sure identiation is correct in the real code. Ciao, Michael. |
From: Guruprasad <lgp...@gm...> - 2009-05-16 13:14:04
|
Hi, 2009/5/16 Michael Ströder <mi...@st...>: > Guruprasad wrote: >> 2009/5/16 Michael Ströder <mi...@st...>: >>> Guruprasad wrote: >>>> Hi, >>>> I tried generating a LDIF file from a dictionary using 'ldif' module >>>> as illustrated in http://www.python-ldap.org/doc/html/ldif.html. But >>>> at the end of the LDIF data, I get a newline and a 'None', whereas >>>> there is no such thing in the result shown in that example. How to get >>>> rid of those unwanted characters. I am using Python-LDAP 2.3.5-1 on >>>> Debian Lenny. >>> Could you please post your code (in a short form) demonstrating the >>> issue? Note that there is a new-line after each entry record. But was >>> 'None' is in your case is not clear to me. >>> >> >> Basically what I am trying to do with this code is that, I manipulate >> the result returned by ldapsearch to remove some attributes and >> generate a LDIF output for the modified entry. >> >> <code> >> res_type, result_data=l.result(res_id,0) >> if (result_data==[]): >> break >> dn=result_data[0][0] >> resd=result_data[0][1] >> resd["objectClass"].remove("inetLocalMailRecipient") >> resd["objectClass"].remove("organizationalPerson") >> resd["objectClass"].remove("inetOrgPerson") >> resd["objectClass"].remove("posixAccount") >> lw=ldif.LDIFWriter(sys.stdout) >> guru=lw.unparse(dn,resd) >> print guru >> </code> > > Your code looks like processing of LDAP search results (because of the > res_type). I'd recommend to look at the actual data in dictionary resd. > Also note that the identiation seems wrong. This could be because of > cut&paste to your MUA from the editor with different tab-interpretation. > But make sure identiation is correct in the real code. > > Ciao, Michael. > The indentation is correct in the real code. The dictionary 'resd' has the values returned by the ldapsearch and there is no 'None' anywhere in it. Thank you. Regards, Guruprasad. |
From: Michael S. <mi...@st...> - 2009-05-16 13:59:51
|
Guruprasad wrote: > Hi, > 2009/5/16 Michael Ströder <mi...@st...>: >> Guruprasad wrote: >>> 2009/5/16 Michael Ströder <mi...@st...>: >>>> Guruprasad wrote: >>>>> Hi, >>>>> I tried generating a LDIF file from a dictionary using 'ldif' module >>>>> as illustrated in http://www.python-ldap.org/doc/html/ldif.html. But >>>>> at the end of the LDIF data, I get a newline and a 'None', whereas >>>>> there is no such thing in the result shown in that example. How to get >>>>> rid of those unwanted characters. I am using Python-LDAP 2.3.5-1 on >>>>> Debian Lenny. >>>> Could you please post your code (in a short form) demonstrating the >>>> issue? Note that there is a new-line after each entry record. But was >>>> 'None' is in your case is not clear to me. >>>> >>> Basically what I am trying to do with this code is that, I manipulate >>> the result returned by ldapsearch to remove some attributes and >>> generate a LDIF output for the modified entry. >>> >>> <code> >>> res_type, result_data=l.result(res_id,0) >>> if (result_data==[]): >>> break >>> dn=result_data[0][0] >>> resd=result_data[0][1] >>> resd["objectClass"].remove("inetLocalMailRecipient") >>> resd["objectClass"].remove("organizationalPerson") >>> resd["objectClass"].remove("inetOrgPerson") >>> resd["objectClass"].remove("posixAccount") >>> lw=ldif.LDIFWriter(sys.stdout) >>> guru=lw.unparse(dn,resd) >>> print guru >>> </code> >> Your code looks like processing of LDAP search results (because of the >> res_type). I'd recommend to look at the actual data in dictionary resd. >> Also note that the identiation seems wrong. This could be because of >> cut&paste to your MUA from the editor with different tab-interpretation. >> But make sure identiation is correct in the real code. > > The indentation is correct in the real code. The dictionary 'resd' has > the values returned by the ldapsearch and there is no 'None' anywhere > in it. I think your interpretation of the output is wrong. Method LDIFWrite.unparse() outputs the LDIF to the file object (in your case sys.stdout). If you print the result of method unparse() that's obviously None. Ciao, Michael. |