from functools import wraps def by_about wraps def wrapper self about

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from functools import wraps
def by_about(f):
@wraps(f)
def wrapper(self, about, *args, **kwargs):
o = self.create_object(about=about)
if type(o) == types.IntType: # error code
return o
return f(self, o.id, *args, **kwargs)
return wrapper
.....
tag_object_by_about = by_about(tag_object_by_id)
untag_object_by_about = by_about(untag_object_by_id)
....