Commit 133966fd authored by Valentin Samir's avatar Valentin Samir

[objets] Méthodes .machines() .factures() .certificats() ne plantent pas si...

[objets] Méthodes .machines() .factures() .certificats() ne plantent pas si l'object ldap n'existe pas (encore).
parent ec8b7b5d
......@@ -1059,9 +1059,12 @@ class proprio(CransLdapObject):
def machines(self, mode=None, refresh=False):
"""Renvoie la liste des machines"""
if self._machines is None or refresh:
self._machines = self.conn.search(u'mid=*', dn = self.dn, scope = 1, mode=self.mode if mode is None else mode)
for m in self._machines:
m._proprio = self
try:
self._machines = self.conn.search(u'mid=*', dn = self.dn, scope = 1, mode=self.mode if mode is None else mode)
for m in self._machines:
m._proprio = self
except ldap.NO_SUCH_OBJECT:
self._machines = []
return self._machines
def factures(self, refresh=False, mode=None):
......@@ -1072,9 +1075,13 @@ class proprio(CransLdapObject):
if self._factures[0].mode != mode:
refresh = True
if self._factures is None or refresh:
self._factures = self.conn.search(u'fid=*', dn = self.dn, scope = 1, mode=mode)
for m in self._factures:
m._proprio = self
try:
self._factures = self.conn.search(u'fid=*', dn = self.dn, scope = 1, mode=mode)
for m in self._factures:
m._proprio = self
# Si on manipule un objet pas encore enregistré dans la la bdd
except ldap.NO_SUCH_OBJECT:
self._factures = []
return self._factures
def delete(self, comm="", login=None):
......@@ -1150,9 +1157,12 @@ class machine(CransLdapObject):
def certificats(self, refresh=False):
"""Renvoie la liste des certificats de la machine"""
if refresh or self._certificats is None:
self._certificats = self.conn.search(u'xid=*', dn = self.dn, scope = 1, mode=self.mode)
for m in self._certificats:
m._machine = self
try:
self._certificats = self.conn.search(u'xid=*', dn = self.dn, scope = 1, mode=self.mode)
for m in self._certificats:
m._machine = self
except ldap.NO_SUCH_OBJECT:
self._certificats = []
return self._certificats
def blacklist_actif(self, excepts=[]):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment