summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-11-27 19:53:10 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-11-27 19:53:10 (GMT)
commit62279bcbb749ce6176cec7e45d4175c677a7e2d3 (patch)
treee0a97879b21a9b80789eb933db252ea48d55d137
parentaeb6585052fb30c2a33625863df07cb6d2584526 (diff)
downloadpratic-62279bcbb749ce6176cec7e45d4175c677a7e2d3.zip
pratic-62279bcbb749ce6176cec7e45d4175c677a7e2d3.tar.gz
pratic-62279bcbb749ce6176cec7e45d4175c677a7e2d3.tar.bz2
Convert encoding for Collectivity field contained non-ascii characters
add missing encoding conversion for cn and postallAddress field of Collectivity, replace last manual usage of encode/decode by calls to isotoutf8
-rw-r--r--idp/extra/modules/directory.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/idp/extra/modules/directory.py b/idp/extra/modules/directory.py
index 5f4717f..a7282b7 100644
--- a/idp/extra/modules/directory.py
+++ b/idp/extra/modules/directory.py
@@ -62,7 +62,10 @@ class Collectivity:
return
new_entry = self.ldap_entry[1].copy()
for attribute in changed:
- new_entry[attribute] = getattr(self, attribute)
+ if attribute in ('cn','postalAddress',):
+ new_entry[attribute] = isotoutf8(getattr(self, attribute))
+ else:
+ new_entry[attribute] = getattr(self, attribute)
if not new_entry[attribute]:
new_entry[attribute] = []
@@ -171,7 +174,7 @@ class Agent:
if type(new_entry[attribute]) is int:
new_entry[attribute] = [str(new_entry[attribute])]
if type(new_entry[attribute]) is str:
- new_entry[attribute] = unicode(new_entry[attribute], 'iso-8859-1').encode('utf-8')
+ new_entry[attribute] = isotoutf8(new_entry[attribute])
if new_entry[attribute] is None:
new_entry[attribute] = []
@@ -185,7 +188,7 @@ class Agent:
raise ldap.ALREADY_EXISTS('cdg59agentSirhCode')
if 'mail' in changed:
- # check for an existing agent with such SIRH code
+ # check for an existing agent with such mail
try:
get_agent_by_email(self.mail)
except KeyError:
@@ -208,7 +211,7 @@ class Agent:
if 'sn' in changed or 'givenName' in changed:
# change common name too
new_entry['cn'] = '%s %s' % (self.givenName, self.sn)
- new_entry['cn'] = unicode(new_entry['cn'], 'iso-8859-1').encode('utf-8')
+ new_entry['cn'] = isotoutf8(new_entry['cn'])
mod_list = ldap.modlist.modifyModlist(self.ldap_entry[1], new_entry)
store = get_store()