Changing Values On A Werkzeug Request Object
I have a request object that comes from werkzeug. I want to change a value on this request object. This is not possible because werkzeug request objects are immutable. I understand
Solution 1:
This is what I came up with:
def make_duplicate_request(request):
"""
Since werkzeug request objects are immutable, this is needed to create an
identical request object with mutable values
"""
class Req(object):
method = 'GET'
path = ''
headers = []
args = []
r = Req()
r.path = request.path
r.headers = request.headers
r.is_xhr = request.is_xhr
r.args = request.args
return r
Maybe no the most elegant solution, but it works.
Post a Comment for "Changing Values On A Werkzeug Request Object"