From: Anil J. <an...@en...> - 2007-02-24 03:14:06
|
(thanks for all the help in my previous posts) Hi, I am seeing a peculiar problem in this area of the code. I don't know exactly how to reproduce it. It almost like I have to wait a while and I see this problem. url = ''.join((self.server, base, '?', attr, '?', scope, '?', filter, '?')) try: print url ldap_url = ldapurl.LDAPUrl(url) print ldap_url.attrs print attr except ValueError: print "Bad URL" The output is: ldap://somehost.com:389/ou=People, o=entic.net?uid?one?mail=an...@en...? [u'uid'] uid Error - <type 'exceptions.TypeError'>: ('expected string in list', u'uid') I am not sure if this is with my Pylons (web development framework) or something specific to python-ldap. Let me know if you can give me pointers on how I can try to troubleshoot this. Thanks, Anil |
From: <mi...@st...> - 2007-02-25 13:01:19
|
Anil Jangity wrote: > (thanks for all the help in my previous posts) > > Hi, > > I am seeing a peculiar problem in this area of the code. I don't know > exactly how to reproduce it. It almost like I have to wait a while and > I see this problem. > > url = ''.join((self.server, base, '?', attr, '?', scope, '?', filter, '?')) > try: > print url > ldap_url = ldapurl.LDAPUrl(url) > print ldap_url.attrs > print attr > except ValueError: > print "Bad URL" > > The output is: > > ldap://somehost.com:389/ou=People, o=entic.net?uid?one?mail=an...@en...? > [u'uid'] > uid > Error - <type 'exceptions.TypeError'>: ('expected string in list', u'uid') I can't reproduce the error since you didn't provide enough code. But this simply works regarding module ldapurl: >>> u=u'ldap://somehost.com:389/ou=People, o=entic.net?uid?one?mail=an...@en...?' >>> ldap_url=ldapurl.LDAPUrl(u) >>> ldap_url.attrs [u'uid'] Ciao, Michael. |
From: <mi...@st...> - 2007-02-25 13:07:59
|
Anil Jangity wrote: > > url = ''.join((self.server, base, '?', attr, '?', scope, '?', filter, '?')) > try: > print url > ldap_url = ldapurl.LDAPUrl(url) BTW: See also 2nd example on http://python-ldap.sourceforge.net/doc/python-ldap/ldapurl-example.html Ciao, Michael. |
From: Anil J. <an...@en...> - 2007-02-26 23:27:04
|
I notice this in other areas of my code as well. Here is a trace of a modify: *** ldap://host:389 - SimpleLDAPObject.modify_ext (('cn=3DShilpa J, uid=3Danilj, ou=3DPeople, o=3Dentic.net', [(0, 'mail', [u'shi...@so...'])], None, None),{}) Error - <type 'exceptions.TypeError'>: ('expected a string in the list', u'shi...@so...') The problem is, it seems work on and off. When the modifications or searches are done without the unicode string, it works. But later when I try to do the same thing again for some reason it trys to do the LDAP operation using unicode lists: [u'abc'] Thats when it fails. Is it something else in my code that is causing it or is something else wrong in the python-ldap? I'll see if I can find more details/code. I was just wondering if you guys knew off the top of your heads... On 2/25/07, Michael Str=F6der <mi...@st...> wrote: > Anil Jangity wrote: > > > > url =3D ''.join((self.server, base, '?', attr, '?', scope, '?', filter,= '?')) > > try: > > print url > > ldap_url =3D ldapurl.LDAPUrl(url) > > BTW: See also 2nd example on > > http://python-ldap.sourceforge.net/doc/python-ldap/ldapurl-example.html > > Ciao, Michael. > |
From: <mi...@st...> - 2007-02-26 23:55:14
|
Anil Jangity wrote: > I notice this in other areas of my code as well. > > Here is a trace of a modify: > > *** ldap://host:389 - SimpleLDAPObject.modify_ext (('cn=Shilpa J, > uid=anilj, ou=People, o=entic.net', [(0, 'mail', > [u'shi...@so...'])], None, None),{}) > Error - <type 'exceptions.TypeError'>: ('expected a string in the > list', u'shi...@so...') > > > The problem is, it seems work on and off. When the modifications or > searches are done without the unicode string, it works. But later > when I try to do the same thing again for some reason it trys to do > the LDAP operation using unicode lists: [u'abc'] > > Thats when it fails. You have to pass solely raw strings to python-ldap since the API does not handle Unicode strings automatically. u'shi...@so...'.encode('utf-8') Ciao, Michael. |
From: <mi...@st...> - 2007-03-14 04:54:59
|
Anil, please keep replies to the python-ldap-dev list. Anil Jangity wrote: > > But, why couldn't python-ldap automatically encode as utf-8? Is it > because of performance issues? Each attribute has different syntax, e.g. 'jpegPhoto' etc. So you have to look at the schema to do the right thing. Or the application has prior knowledge like most people are implementing it. Strictly speaking in case of attribute 'mail' one would have to encode as 'ascii' since the LDAP syntax for this is IA5String and ASCII is the closest to this. Ciao, Michael. |