Hey, I've been trying to implement a PayPal IPN with Flask, and it's a bit
of a PITA due to the need to process arguments completely in order. I
figured out that I could set parameter_storage_class to
ImmutableOrderedMultiDict to accomplish this. I didn't want to do it by
giving the app a custom Request class, because I didn't want the
performance hit of using ImmutableOrderedMultiDict for *all* requests. One
way to do it was inside the handler itself:
@app.route('/url/path', methods=['POST'])
def my_handler():
request.parameter_storage_class = ImmutableOrderedMultiDict
#stuff ...
It felt ugly doing it inside the request handler function itself.
I wanted a way to override it more decoratively at rule binding time...
something that looks like:
@app.route('/url/path', methods=['POST'],
parameter_storage_class=ImmutableOrderedMultiDict)
def my_handler():
pass
#stuff ...
I couldn't figure out a way to accomplish that terribly cleanly. The best I
could come up with was to create a customer dector called @ordered_storage
that would decorate the handler function before it was called. I've posted
my sample code as a Gist:
https://gist.github.com/cbsmith/5069769
This was all done to make a working PayPal IPN handler, so if anyone needs
to do that, the example shows how to implement a basic one. I'd appreciate
any feedback on the "right" way to do this kind of thing, as I'm still a
bit of a Flask/Werkzeug novice, and this is some pretty low level jujitsu.
Thanks in advance.
--Chris
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.