21dotco / two1-python

The 21 command line interface and two1 bitcoin library. Send and receive BTC over HTTP.
https://earn.com
Other
365 stars 91 forks source link

Flask_Decorator: Allow function args to be passed to pricing handler #9

Closed pooleja closed 8 years ago

pooleja commented 8 years ago

During implementation of a pricing handler, I wanted the URL variable to be accessible. This change allows the flask payment required function to also pass the fn_args, fn_kwargs to the pricing handler so all variables are accessible there as well.

Here is an example of what I wanted to be able to do. I wanted to access the "val" url variable defined in the app.route() definition.

def get_price_for_url(request, val):
  return val * 100

@app.route('/buy/<int:val>')
@payment.required(get_price_for_url)
def buy(val):
  if val > 100
    return json.dumps({"success": True})
  else
    return json.dumps({"success": False})
wbnns commented 8 years ago

@pooleja Thanks for submitting this. We'll review and will be in touch!

jianli commented 8 years ago

Thanks @pooleja! This patch has been deployed as part of our 3.8.0 release.