From 94cacc6bdf4a45090e87408896221c8289a52658 Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Tue, 24 Apr 2012 04:40:20 +0200 Subject: [PATCH] =?UTF-8?q?[attributs]=20Liste=20d'attributs=20vide=20(jam?= =?UTF-8?q?ais=20d=C3=A9finie)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lc_ldap.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lc_ldap.py b/lc_ldap.py index 24a558e..95690cf 100644 --- a/lc_ldap.py +++ b/lc_ldap.py @@ -363,8 +363,15 @@ class CransLdapObject(object): def __getitem__(self, attr): if self.mode in [ 'w', 'rw' ]: return [ v for v in self._modifs[attr] ] - else: + elif self.attrs.has_key(attr): return [ v for v in self.attrs[attr] ] + elif self.has_key(attr): + return [] + raise KeyError(attr) + + def has_key(self,attr): + return attr in self.ofields or attr in self.xfields or\ + attr in self.ufields or attr in self.mfields def __setitem__(self, attr, values): if self.mode not in ['w', 'rw']: @@ -596,7 +603,7 @@ class machineCrans(machine): ofields = machine.ofields + ['nombrePrises'] class borneWifi(machine): - ufields = machine.ufields + ['canal', 'puissane', 'hotspot', + ufields = machine.ufields + ['canal', 'puissance', 'hotspot', 'prise', 'positionBorne', 'nvram'] class facture(CransLdapObject):