From 8a6e93a38a25ed4f93df73cc175d9704938b446c Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Tue, 18 Mar 2014 22:47:35 +0100 Subject: [PATCH] =?UTF-8?q?[objets]=20Methode=20pour=20mettre=20=C3=A0=20j?= =?UTF-8?q?our=20la=20liste=20attribs=20des=20attributs=20possible=20de=20?= =?UTF-8?q?l'objets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La méthode est apprlé dès que attrs et _modis sont instancié et avant les vérifications sur la correction des attributs. Cela permet d'utiliser des objet "Auxilière" dans ldap plus facilement. --- objets.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/objets.py b/objets.py index daf9e36..3e0615c 100644 --- a/objets.py +++ b/objets.py @@ -108,6 +108,13 @@ class CransLdapObject(object): attribs = [] + def update_attribs(self): + """ + Fonction permettant de mettre à jours attribs, dès que les valeurs + des attributs ont été instancié + """ + pass + def __init__(self, conn, dn, mode='ro', uldif=None, lockId=None): ''' Créée une instance d'un objet Crans (machine, adhérent, @@ -158,6 +165,8 @@ class CransLdapObject(object): self.mode = mode + self.update_attribs() + if mode in ['w', 'rw']: # Vérification que `λv. str(Attr(v))` est bien une projection # C'est-à-dire que si on str(Attr(str(Attr(v)))) on retombe sur str(Attr(v)) @@ -1261,15 +1270,13 @@ class baseCert(CransLdapObject): def __repr__(self): return str(self.__class__) + " : xid=" + str(self['xid'][0]) - def __init__(self, *args, **kwargs): - super(baseCert, self).__init__(*args, **kwargs) + def update_attribs(self): if "TLSACert" in self['objectClass']: self.attribs.extend(self.tlsa_attribs) if 'x509Cert' in self['objectClass']: self.attribs.extend(self.x509_attribs) if "privateKey" in self['objectClass']: self.attribs.extend(self.private_attribs) - super(baseCert, self).__init__(*args, **kwargs) def _check_setitem(self, attr, values): """