[fix] mixed inheritance between osv and osv_memory, add direct osv_base holding redundancies between osv and osv_memory and forcing resolution of its __init__ before going higher the class tree

bzr revid: xmo@tinyerp.com-20091217192139-z9pnlw7d0438u89q
This commit is contained in:
Xavier Morel 2009-12-17 20:21:39 +01:00
parent 91370e8668
commit 5d15a496b1
2 changed files with 8 additions and 29 deletions

View File

@ -1531,7 +1531,7 @@ class orm_memory(orm_template):
_check_time = 20
def __init__(self, cr):
orm_template.__init__(self, cr)
super(orm_memory, self).__init__(cr)
self.datas = {}
self.next_id = 0
self.check_id = 0

View File

@ -171,9 +171,12 @@ class osv_pool(netsvc.Service):
res.append(klass.createInstance(self, module, cr))
return res
class osv_base(object):
def __init__(self, pool, cr):
pool.add(self._name, self)
self.pool = pool
super(osv_base, self).__init__(cr)
class osv_memory(orm.orm_memory):
#__metaclass__ = inheritor
def __new__(cls):
module = str(cls)[6:]
module = module[:len(module)-1]
@ -186,6 +189,7 @@ class osv_memory(orm.orm_memory):
module_list.append(cls._module)
return None
class osv_memory(osv_base, orm.orm_memory):
#
# Goal: try to apply inheritancy at the instanciation level and
# put objects in the pool var
@ -213,27 +217,7 @@ class osv_memory(orm.orm_memory):
return obj
createInstance = classmethod(createInstance)
def __init__(self, pool, cr):
pool.add(self._name, self)
self.pool = pool
orm.orm_memory.__init__(self, cr)
class osv(orm.orm):
#__metaclass__ = inheritor
def __new__(cls):
module = str(cls)[6:]
module = module[:len(module)-1]
module = module.split('.')[0][2:]
if not hasattr(cls, '_module'):
cls._module = module
module_class_list.setdefault(cls._module, []).append(cls)
class_pool[cls._name] = cls
if module not in module_list:
module_list.append(cls._module)
return None
class osv(osv_base, orm.orm):
#
# Goal: try to apply inheritancy at the instanciation level and
# put objects in the pool var
@ -270,10 +254,5 @@ class osv(orm.orm):
return obj
createInstance = classmethod(createInstance)
def __init__(self, pool, cr):
pool.add(self._name, self)
self.pool = pool
orm.orm.__init__(self, cr)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: