-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow redirects through to user #162
Conversation
Okay - upon further investigation, this issue makes more sense and has a slightly different solution than I initially committed. Because flask.Response is derived from werkzeug.wrappers.Response, we should check werkzeug's Response via isinstance, rather than Flask's, as werkzeug's will not match an isinstance check (though they serve the same purpose for us) Furthermore, my earlier code tests apples against oranges. I was testing two very distinct scenarios. Please ignore it, but I'll leave it up for posterity's sake. |
+1 I needed this the other day. Returning a Redirect object in a Restful.Response inherited class will result in "Response 302 not JSON Serializable". This pull-request fixes that. Here is a example of the problem from flask import Flask, redirect
from flask.ext import restful
app = Flask(__name__)
api = restful.Api(app)
class HelloWorld(restful.Resource):
def get(self):
return redirect('/')
api.add_resource(HelloWorld, '/api/')
@app.route('/')
def index():
return "Hello World"
if __name__ == "__main__":
app.debug = True
app.run() // lance |
Does anyone have any thoughts on this? |
+1 I need this in my life. Any idea on PR status? Seems straightforward enough... |
Looks reasonable to me. I'll use the provided example problem code to write up a quick test for this behavior. Thanks! |
Allow redirects through to user
I'm deleting my branch since this is merged. Glad to see it pulled in. Thanks, @skimbrel! |
For some reason flask.redirect returns a response that is derived from werkzeug.wrappers.Response, rather than flask.Response. Testing with some dummy code proves this problem to be a bit inconsistent:
This conflicts with what I see with Flask / Flask-Restful:
The code on this branch fixes this, but there may be a better way to fix this problem. I'd be open to hearing and possibly implementing any other ideas. Do you guys have any other thoughts?