[IMP] ir.property: fixed compatibility with python 2.5

bzr revid: odo@openerp.com-20100924101545-2baak1xfh0v8z04n
This commit is contained in:
Olivier Dony 2010-09-24 12:15:45 +02:00
parent 35acf33537
commit e4e6e04a61
2 changed files with 21 additions and 1 deletions

View File

@ -20,8 +20,9 @@
##############################################################################
from osv import osv,fields
from operator import attrgetter
from tools.misc import attrgetter
import time
# -------------------------------------------------------------------------
# Properties
# -------------------------------------------------------------------------

View File

@ -1406,5 +1406,24 @@ def upload_data(email, data, type='SURVEY'):
a = upload_data_thread(email, data, type)
a.start()
return True
# port of python 2.6's attrgetter with support for dotted notation
def resolve_attr(obj, attr):
for name in attr.split("."):
obj = getattr(obj, name)
return obj
def attrgetter(*items):
if len(items) == 1:
attr = items[0]
def g(obj):
return resolve_attr(obj, attr)
else:
def g(obj):
return tuple(resolve_attr(obj, attr) for attr in items)
return g
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: