[Zope-CVS] SVN: ldapadapter/trunk/utility.py Convert from unicode to UTF-8, and attrs must be ASCII strings.

Florent Guillaume fg at nuxeo.com
Wed Oct 13 16:42:51 EDT 2004


Log message for revision 28122:
  Convert from unicode to UTF-8, and attrs must be ASCII strings.
  

Changed:
  U   ldapadapter/trunk/utility.py

-=-
Modified: ldapadapter/trunk/utility.py
===================================================================
--- ldapadapter/trunk/utility.py	2004-10-13 20:37:20 UTC (rev 28121)
+++ ldapadapter/trunk/utility.py	2004-10-13 20:42:51 UTC (rev 28122)
@@ -94,6 +94,7 @@
     def add(self, dn, entry):
         attrs_list = []
         for key, values in entry.items():
+            key = str(key)
             attrs_list.append((key, valuesToUTF8(values)))
         self.conn.add_s(dn.encode('utf-8'), attrs_list)
 
@@ -109,6 +110,7 @@
 
         mod_list = []
         for key, values in entry.items():
+            key = str(key)
             if cur_entry.has_key(key):
                 if values == []:
                     # TODO fail on rdn removal
@@ -127,10 +129,12 @@
 
     def search(self, base, scope='sub', filter='(objectClass=*)',
                attrs=None):
-        # Convert from unicode to utf-8.
+        # Convert from unicode to UTF-8, and attrs must be ASCII strings.
         base = base.encode('utf-8')
         scope = convertScope(scope)
-        # XXX convert filter to utf-8
+        filter = filter.encode('utf-8')
+        if attrs is not None:
+            attrs = [str(attr) for attr in attrs]
         try:
             ldap_entries = self.conn.search_s(base, scope, filter, attrs)
         except ldap.NO_SUCH_OBJECT:



More information about the Zope-CVS mailing list