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 this design decision, but I need to change a value. How do I do this?
>>> request
<Request 'http://localhost:5000/new' [POST]>
>>> request.method
'POST'
>>> request.method = 'GET'
*** AttributeError: read only property
I tried doing a deepcopy, but the resulting copy is immutable also. I guess I could just create my own mock object and fill in the values manually, but that is my last resort solution. Is there a better way?
This is what I came up with:
Maybe no the most elegant solution, but it works.