From f988e962c973aaa45da8136ed3cc61a07aad9a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Tue, 18 Aug 2015 04:16:02 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20m=C3=A9thodes=20=5F=5Funicode=5F?= =?UTF-8?q?=5F=20sur=20les=20objets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- objets.py | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/objets.py b/objets.py index 9d01651..d05fc62 100644 --- a/objets.py +++ b/objets.py @@ -848,8 +848,11 @@ def crans_object(classe): class InetOrgPerson(CransLdapObject): __slots__ = () ldap_name = "inetOrgPerson" + def __unicode__(self): + return u"%s : cn=%s" % (self.__class__.__name__, self['cn'][0]) + def __repr__(self): - return str(self.__class__.__name__) + " : cn=" + str(self['cn'][0]) + return str(self.__unicode__()) pass class proprio(CransLdapObject): @@ -889,8 +892,11 @@ class proprio(CransLdapObject): """Renvoie la liste des clubs dont l'adherent est imprimeur (surchargée dans les objets adherent)""" return [] + def __unicode__(self): + return u"%s : nom=%s" % (self.__class__.__name__, self['nom'][0]) + def __repr__(self): - return str(self.__class__.__name__) + " : nom=" + str(self['nom'][0]) + return str(self.__unicode__()) def __init__(self, *args, **kwargs): super(proprio, self).__init__(*args, **kwargs) @@ -1166,8 +1172,11 @@ class machine(CransLdapObject): attributs.ipHostNumber, attributs.ip6HostNumber, attributs.historique, attributs.dnsIpv6, attributs.machineAlias] + def __unicode__(self): + return u"%s : host=%s" % (self.__class__.__name__, self['host'][0]) + def __repr__(self): - return str(self.__class__.__name__) + " : host=" + str(self['host'][0]) + return str(self.__unicode__()) def __init__(self, *args, **kwargs): super(machine, self).__init__(*args, **kwargs) @@ -1344,14 +1353,21 @@ class AssociationCrans(proprio): def delete(self, comm, login): pass + + def __unicode__(self): + return u"Le Crans" + def __repr__(self): - return str(self.__class__.__name__) + " : Le Crans" + return str(self.__unicode__()) class BaseInvites(proprio): u"""Un artefact de la base ldap""" __slots__ = () + def __unicode__(self): + return u"%s" % (self.__class__.__name__,) + def __repr__(self): - return str(self.__class__.__name__) + return str(self.__unicode__()) def delete(self, comm, login): raise EnvironmentError("Les pauvres invites") @@ -1371,8 +1387,11 @@ class adherent(proprio): ] ldap_name = "adherent" + def __unicode__(self): + return u"Adhérent : %s %s" % (self['prenom'][0], self['nom'][0]) + def __repr__(self): - return "Adhérent : " + str(self['prenom'][0]) + " " + str(self['nom'][0]) + return str(self.__unicode__()) def __init__(self, *args, **kwargs): super(adherent, self).__init__(*args, **kwargs) @@ -1415,8 +1434,11 @@ class club(proprio): def __init__(self, *args, **kwargs): super(club, self).__init__(*args, **kwargs) + def __unicode__(self): + return u"Club : %s" % (self['nom'][0],) + def __repr__(self): - return "Club : " + str(self['nom'][0]) + return str(self.__unicode__()) @crans_object class machineFixe(machine): @@ -1508,8 +1530,11 @@ class facture(CransLdapObject): attributs.finConnexion, attributs.controle ] ldap_name = "facture" + def __unicode__(self): + return u"Facture : fid=%s" % (self['fid'][0],) + def __repr__(self): - return str(self.__class__.__name__) + " : fid=" + str(self['fid'][0]) + return str(self.__unicode__()) def __init__(self, *args, **kwargs): self._proprio = None