[lc_ldap, objets] vivent les __repr__

This commit is contained in:
Valentin Samir 2014-02-23 00:02:00 +01:00
parent 7df0a4e1a0
commit 99ba3a8915
2 changed files with 20 additions and 2 deletions

View file

@ -132,6 +132,12 @@ class lc_ldap(ldap.ldapobject.LDAPObject, object):
self.droits = [] self.droits = []
self._username_given = user self._username_given = user
def __repr__(self):
if self.dn:
return str(self.__class__) + " : " + self.dn
else:
return super(lc_ldap, self).__repr__()
def gravedig(self, type, filter=None, date=None): def gravedig(self, type, filter=None, date=None):
"""Cherche dans le cimetière un objet de type ``type``, """Cherche dans le cimetière un objet de type ``type``,
correspondant au filtre ``filter`` entre les dates ``date[0]`` et ``date[1]`` correspondant au filtre ``filter`` entre les dates ``date[0]`` et ``date[1]``

View file

@ -610,7 +610,7 @@ class proprio(CransLdapObject):
attribs = [attributs.nom, attributs.chbre, attributs.paiement, attributs.info, attributs.blacklist, attributs.controle, attributs.historique] attribs = [attributs.nom, attributs.chbre, attributs.paiement, attributs.info, attributs.blacklist, attributs.controle, attributs.historique]
def __repr__(self): def __repr__(self):
return str(self.__class__) + " : " + str(self['nom'][0]) return str(self.__class__) + " : nom=" + str(self['nom'][0])
def __init__(self, conn, dn, mode='ro', ldif=None): def __init__(self, conn, dn, mode='ro', ldif=None):
super(proprio, self).__init__(conn, dn, mode, ldif) super(proprio, self).__init__(conn, dn, mode, ldif)
@ -720,7 +720,7 @@ class machine(CransLdapObject):
attributs.dnsIpv6, attributs.machineAlias] attributs.dnsIpv6, attributs.machineAlias]
def __repr__(self): def __repr__(self):
return str(self.__class__) + " : " + str(self['host'][0]) return str(self.__class__) + " : host=" + str(self['host'][0])
def __init__(self, conn, dn, mode='ro', ldif = None): def __init__(self, conn, dn, mode='ro', ldif = None):
super(machine, self).__init__(conn, dn, mode, ldif) super(machine, self).__init__(conn, dn, mode, ldif)
@ -883,6 +883,9 @@ class adherent(proprio):
] ]
ldap_name = "adherent" ldap_name = "adherent"
def __repr__(self):
return str(self.__class__) + " : aid=" + str(self['aid'][0])
def __init__(self, conn, dn, mode='ro', ldif=None): def __init__(self, conn, dn, mode='ro', ldif=None):
super(adherent, self).__init__(conn, dn, mode, ldif) super(adherent, self).__init__(conn, dn, mode, ldif)
self.full = False self.full = False
@ -967,6 +970,9 @@ class club(proprio):
attribs = proprio.attribs + [attributs.cid, attributs.responsable, attributs.imprimeurClub] attribs = proprio.attribs + [attributs.cid, attributs.responsable, attributs.imprimeurClub]
ldap_name = "club" ldap_name = "club"
def __repr__(self):
return str(self.__class__) + " : cid=" + str(self['cid'][0])
@crans_object @crans_object
class machineFixe(machine): class machineFixe(machine):
u"""Machine fixe""" u"""Machine fixe"""
@ -1050,6 +1056,9 @@ class facture(CransLdapObject):
_proprio = None _proprio = None
def __repr__(self):
return str(self.__class__) + " : fid=" + str(self['fid'][0])
#### GROS HACK pour rester comptatible avec ldap_crans où l'article representant les frais n'est ajouté qu'une fois le paiement reçu #### GROS HACK pour rester comptatible avec ldap_crans où l'article representant les frais n'est ajouté qu'une fois le paiement reçu
def __init__(self, conn, dn, mode='ro', ldif=None): def __init__(self, conn, dn, mode='ro', ldif=None):
super(facture, self).__init__(conn, dn, mode, ldif) super(facture, self).__init__(conn, dn, mode, ldif)
@ -1098,6 +1107,9 @@ class baseCert(CransLdapObject):
_machine = None _machine = None
def __repr__(self):
return str(self.__class__) + " : xid=" + str(self['xid'][0])
def __init__(self, conn, dn, mode='ro', ldif=None): def __init__(self, conn, dn, mode='ro', ldif=None):
super(baseCert, self).__init__(conn, dn, mode, ldif) super(baseCert, self).__init__(conn, dn, mode, ldif)
if "TLSACert" in self['objectClass']: if "TLSACert" in self['objectClass']: