[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:
parent
91370e8668
commit
5d15a496b1
|
@ -1531,7 +1531,7 @@ class orm_memory(orm_template):
|
||||||
_check_time = 20
|
_check_time = 20
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
orm_template.__init__(self, cr)
|
super(orm_memory, self).__init__(cr)
|
||||||
self.datas = {}
|
self.datas = {}
|
||||||
self.next_id = 0
|
self.next_id = 0
|
||||||
self.check_id = 0
|
self.check_id = 0
|
||||||
|
|
|
@ -171,9 +171,12 @@ class osv_pool(netsvc.Service):
|
||||||
res.append(klass.createInstance(self, module, cr))
|
res.append(klass.createInstance(self, module, cr))
|
||||||
return res
|
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):
|
def __new__(cls):
|
||||||
module = str(cls)[6:]
|
module = str(cls)[6:]
|
||||||
module = module[:len(module)-1]
|
module = module[:len(module)-1]
|
||||||
|
@ -186,6 +189,7 @@ class osv_memory(orm.orm_memory):
|
||||||
module_list.append(cls._module)
|
module_list.append(cls._module)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
class osv_memory(osv_base, orm.orm_memory):
|
||||||
#
|
#
|
||||||
# Goal: try to apply inheritancy at the instanciation level and
|
# Goal: try to apply inheritancy at the instanciation level and
|
||||||
# put objects in the pool var
|
# put objects in the pool var
|
||||||
|
@ -213,27 +217,7 @@ class osv_memory(orm.orm_memory):
|
||||||
return obj
|
return obj
|
||||||
createInstance = classmethod(createInstance)
|
createInstance = classmethod(createInstance)
|
||||||
|
|
||||||
def __init__(self, pool, cr):
|
class osv(osv_base, orm.orm):
|
||||||
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
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Goal: try to apply inheritancy at the instanciation level and
|
# Goal: try to apply inheritancy at the instanciation level and
|
||||||
# put objects in the pool var
|
# put objects in the pool var
|
||||||
|
@ -270,10 +254,5 @@ class osv(orm.orm):
|
||||||
return obj
|
return obj
|
||||||
createInstance = classmethod(createInstance)
|
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:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue