Document API: fix equality operators

They must first check for the type of the 'other' side, or attribute
errors may occur.

bzr revid: p_christ@hol.gr-20100701175133-mjauo28qv6vkqfuq
This commit is contained in:
P. Christeas
2010-07-01 20:51:33 +03:00
parent 1819f137e9
commit 9cdbcbfee1
+8 -8
View File
@@ -392,10 +392,10 @@ class node_dir(node_database):
pass
def __eq__(self, other):
if not self.context == other.context:
return False
if type(self) != type(other):
return False
if not self.context == other.context:
return False
# Two directory nodes, for the same document.directory, may have a
# different context! (dynamic folders)
if self.dctx != other.dctx:
@@ -526,10 +526,10 @@ class node_res_dir(node_class):
self.dctx_dict['dctx_' + dfld.field] = dfld.expr
def __eq__(self, other):
if not self.context == other.context:
return False
if type(self) != type(other):
return False
if not self.context == other.context:
return False
# Two nodes, for the same document.directory, may have a
# different context! (dynamic folders)
if self.dctx != other.dctx:
@@ -640,10 +640,10 @@ class node_res_obj(node_class):
self.res_id = res_id
def __eq__(self, other):
if not self.context == other.context:
return False
if type(self) != type(other):
return False
if not self.context == other.context:
return False
if not self.res_model == other.res_model:
return False
if not self.res_id == other.res_id:
@@ -852,10 +852,10 @@ class node_file(node_class):
par = par.parent_id
def __eq__(self, other):
if not self.context == other.context:
return False
if type(self) != type(other):
return False
if not self.context == other.context:
return False
if self.dctx != other.dctx:
return False
return self.file_id == other.file_id