diff options
| author | Olivier Dony <odo@openerp.com> | 2010-09-24 12:15:45 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2010-09-24 12:15:45 +0200 |
| commit | e4e6e04a61d6cb87b2d3e5ec278cad69ae88a895 (patch) | |
| tree | 401e43e077a23ea7c6e50f428d39f918a87ba901 /bin/tools/misc.py | |
| parent | 35acf33537fcf0fbe8532efe0b0c4b1b55aa986d (diff) | |
[IMP] ir.property: fixed compatibility with python 2.5
bzr revid: odo@openerp.com-20100924101545-2baak1xfh0v8z04n
Diffstat (limited to 'bin/tools/misc.py')
| -rw-r--r-- | bin/tools/misc.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bin/tools/misc.py b/bin/tools/misc.py index ad422411d29..5a3d21bef86 100644 --- a/bin/tools/misc.py +++ b/bin/tools/misc.py @@ -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: |
