Use function name instead of address in _constraints

This commit is contained in:
Cédric Krier
2008-02-15 15:48:41 +01:00
parent 0bf725f14d
commit eef94ef9f7
3 changed files with 7 additions and 12 deletions
+4 -5
View File
@@ -29,8 +29,11 @@ class View(OSV):
'module': lambda obj, cursor, user, context: context.get('module', ''),
}
_order = "priority"
_constraints = [
('check_xml', 'Invalid XML for View Architecture!', ['arch'])
]
def _check_xml(self, cursor, user, ids):
def check_xml(self, cursor, user, ids):
"Check XML"
views = self.browse(cursor, user, ids)
cursor.execute('SELECT id, name, src FROM ir_translation ' \
@@ -100,10 +103,6 @@ class View(OSV):
(view.model, 'view') + tuple(strings))
return True
_constraints = [
(_check_xml, 'Invalid XML for View Architecture!', ['arch'])
]
def unlink(self, cursor, user, ids, context=None):
if isinstance(ids, (int, long)):
+1 -1
View File
@@ -1177,7 +1177,7 @@ class ORM(object):
field_error = []
field_err_str = []
for field in self._constraints:
if not field[0](self, cursor, user, ids):
if not getattr(self, field[0])(cursor, user, ids):
if len(field) > 1:
field_error += field[2]
field_err_str.append(field[1])
+2 -6
View File
@@ -25,13 +25,9 @@ class Directory(OSV):
('name_parent_uniq', 'UNIQUE (name, parent)',
'The directory name must be unique inside a directory!'),
]
def check_recursion(self, cursor, user, ids, parent=None):
return super(Directory, self).check_recursion(cursor, user, ids,
parent='parent')
_parent_name = 'parent'
_constraints = [
(check_recursion,
('check_recursion',
'Error! You can not create recursive directories.', ['parent']),
]
ext2mime = {