[FIX] fix bug with functools on python 2.4

bzr revid: christophe@tinyerp.com-20081212114945-jh7djsx6dv8sr1kh
This commit is contained in:
Christophe Simonis 2008-12-12 12:49:45 +01:00
parent 6706f6b07b
commit a9e7204533
3 changed files with 34 additions and 2 deletions

View File

@ -62,7 +62,8 @@ class Cursor(object):
count = 0
def check(f):
from functools import wraps
from tools.func import wraps
@wraps(f)
def wrapper(self, *args, **kwargs):
if not hasattr(self, '_obj'):

31
bin/tools/func.py Normal file
View File

@ -0,0 +1,31 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
try:
from functools import wraps
except ImportError:
# this module doesn't exist in python < 2.5
# we define a identity decorator
def wraps(f):
def identity(x):
return x
return identity

View File

@ -689,7 +689,7 @@ def human_size(sz):
return "%0.2f %s" % (s, units[i])
def logged(f):
from functools import wraps
from tools.func import wraps
@wraps(f)
def wrapper(*args, **kwargs):