From 4fbd45b66c43ea1f2ef9a58925d0a7b5a3588f2d Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Tue, 16 Jul 2013 20:11:30 +0200 Subject: [PATCH] [objects] check_changes renvoie toujours comme mon estomac --- objets.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/objets.py b/objets.py index 119d92d..cd7d68b 100644 --- a/objets.py +++ b/objets.py @@ -653,11 +653,13 @@ class machine(CransLdapObject): self._proprio._machines.remove(self) def check_changes(self): + """ EXPLAIN WAT U DO !!!""" old = {} new = {} sbm = {'rid' : (), 'ipHostNumber' : (), 'ip6HostNumber' : ()} default = {'rid': -1, 'ipHostNumber': u'', 'macAddress': u''} for i in ['rid', 'ipHostNumber', 'macAddress']: + # Try and may fail, then try again try: old[i] = self.attrs[i][0].value except: @@ -678,13 +680,13 @@ class machine(CransLdapObject): oip6 = u"" if oip6 != nip6: sbm['ip6HostNumber'] = (oip6, nip6) - return sbm + # safer to cast everything to unicode elif unicode(old['ipHostNumber']) != unicode(new['ipHostNumber']): nrid = crans_utils.rid_of_ip4(new['ipHostNumber']) orid = new['rid'] if nrid != orid: sbm['rid'] = (orid, nrid) - return sbm + # safer not to cast (…) elif old['macAddress'] != new['macAddress']: nip6 = unicode(crans_utils.ip6_of_mac(new['macAddress'], new['rid'])) try: @@ -693,7 +695,7 @@ class machine(CransLdapObject): oip6 = u"" if oip6 != nip6: sbm['ip6HostNumber'] = (oip6, nip6) - return sbm + return sbm def validate_changes(self): sbm = self.check_changes()