Gestion de l'encodage dans config.
This commit is contained in:
parent
2f469b4916
commit
991a8efaa4
1 changed files with 4 additions and 3 deletions
|
@ -52,6 +52,7 @@ from crans_utils import to_generalized_time_format, from_generalized_time_format
|
|||
import itertools
|
||||
|
||||
sys.path.append("/usr/scripts")
|
||||
|
||||
import cranslib.deprecated
|
||||
from gestion import config
|
||||
from gestion import annuaires_pg
|
||||
|
@ -129,7 +130,7 @@ def attrify(val, attr, conn, Parent=None):
|
|||
attr_classe = AttributeFactory.get(attr, fallback=Attr)
|
||||
if not isinstance(val, unicode) and not (attr_classe.python_type and isinstance(val, attr_classe.python_type)):
|
||||
cranslib.deprecated.usage("attrify ne devrait être appelé qu'avec des unicode (%r)" % val, level=3)
|
||||
val = val.decode('utf-8')
|
||||
val = val.decode(config.in_encoding)
|
||||
return attr_classe(val, conn, Parent)
|
||||
|
||||
class AttrsList(list):
|
||||
|
@ -321,7 +322,7 @@ class Attr(object):
|
|||
self.value = val
|
||||
|
||||
def __str__(self):
|
||||
return self.__unicode__().encode('utf-8')
|
||||
return self.__unicode__().encode(config.out_encoding)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self.__class__) + " : " + repr(self.value)
|
||||
|
@ -1539,7 +1540,7 @@ class modePaiement(Attr):
|
|||
|
||||
def parse_value(self, mode):
|
||||
if not mode in config.modePaiement:
|
||||
raise ValueError("%s n'est pas un moyen de paiement accepté. Les moyens accepté sont %s" % ", ".join(config.modePaiement))
|
||||
raise ValueError("%s n'est pas un moyen de paiement accepté. Les moyens accepté sont %s. (debug=%s)" % (mode.encode(config.out_encoding), ", ".join(config.modePaiement), self.parent.dn))
|
||||
self.value = mode
|
||||
|
||||
@crans_attribute
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue