function (no side-effects) def aspect(function): def advice(*args, **kwargs): result = function(*args, **kwargs) do something here return result return advice
the function def aspect(function): def advice(*args, **kwargs): do something here result = function(*args, **kwargs) do something here return result return advice
advice(format, *args, **kwargs): if not format in ['html', 'xml', 'json']: raise exception result = function(*args, **kwargs) make a http response of 'result' in the right format return advice