-
Notifications
You must be signed in to change notification settings - Fork 58
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
AbsoluteURLFor: Field parameters are passed to URL #67
Comments
I ran into this same limitation or side effect as I wanted to add player_url = AbsoluteURLFor('players.entry', player_id='<player_id>')
player_url.metadata['description'] = "Fully qualified URL of the player resource" I wrote a wrapper for this particular case: def Url(endpoint, **kwargs):
"""
Returns AbsoluteURLFor field. If 'kwargs' contains 'doc' it will not be passed to
AbsoluteURLFor but instead added to the metadata of the parent class as 'description'.
"""
doc = kwargs.pop('doc')
url = AbsoluteURLFor(endpoint, **kwargs)
if doc:
url.metadata['description'] = doc
return url One potential fix is to tag which parameters should not be forwarded to url_for by prefixing them with an underscore. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use
AbsoluteURLFor
for generating an URL to an image:The resulting response is:
The expected result is:
If I skip the
dump_to
-parameter the result is:This is because the field parameter
dump_to
is passed as a parameter toflask.url_for
. But this is (of course) not my intention. Can this be fixed or do I have to use another field likeFunction
for example?The text was updated successfully, but these errors were encountered: