You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because the field parameter dump_to is passed as a parameter to flask.url_for. But this is (of course) not my intention. Can this be fixed or do I have to use another field like Function for example?
The text was updated successfully, but these errors were encountered:
I ran into this same limitation or side effect as I wanted to add description to the Field class metadata. One work-around looked something like this:
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:
defUrl(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)
ifdoc:
url.metadata['description'] =docreturnurl
One potential fix is to tag which parameters should not be forwarded to url_for by prefixing them with an underscore.
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: