Skip to content

Instantly share code, notes, and snippets.

@mdippery
Created July 26, 2013 17:47
Show Gist options
  • Save mdippery/6090795 to your computer and use it in GitHub Desktop.
Save mdippery/6090795 to your computer and use it in GitHub Desktop.
def ensure_subscription(fn):
@wraps(fn)
def _ensure_subscription(user, other, trade):
unsubscribe_code = user.profile.get_unsubscribe_code('trade-notifications')
if unsubscribe_code is None:
return
fn_globals = {}
fn_globals.update(globals())
fn_globals['unsubscribe_code'] = unsubscribe_code
call_fn = FunctionType(fn.func_code, fn_globals)
return call_fn(user, other, trade)
return _ensure_subscription
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment