I can't actually run this, but I think it would do what you say want, It creates awrapper()
function that calls the original (which now just returns an object list) and then post-processes it (but returns nothing itself):
from functools import wraps
def raw_turn_over_mailer(function):
@wraps(function)
def wrapper(requests):
object_list = function(requests) # call original
if object_list:
#....
return wrapper
@raw_turn_over_mailer
def one(requests):
return [x for x in requests if x.account_type.name == 'AccountType1']
@raw_turn_over_mailer
def two(requests):
return [x for x in requests if x.account_type.name == 'AccountType2']
This seems like a convoluted way to process the results of calling a function. You could just call the post-processing function and pass it the function to call to get the object list.