Issue #7032
closedProvide a way for subclasses of pulp viewset that use serializers with href methods to override urls that are reversed
Description
Ticket moved to GitHub: "pulp/pulp_ansible/710":https://github.com/pulp/pulp_ansible/issues/710
This is related to https://github.com/ansible/galaxy_ng/pull/254 and https://github.com/ansible/galaxy_ng/issues/247
To paraphrase https://github.com/ansible/galaxy_ng/issues/247#issuecomment-644886557:
The serializers used by the pulp collection viewsets (and therefore galaxy_ng collection viewsets) base the values for 'href' on url reverse() lookups, and end up with the pulp paths.
May mean galaxy_ng viewsets need to provide their own serializer.
But may be able to parameterize the reverse()'s to handle both cases. Possibly via providing a ViewSet.get_serializer_context()
https://github.com/ansible/galaxy_ng/pull/254 is a fix / workaround that is based on subclassing the related pulp collection Serializers and overriding the href related SerializerMethodFields methods.
ie, the 'get_href()' and similar methods.
The changes in #254 are kind of cut&paste and duplicate a chunk of pulp_ansible code (and diverge from upstream as a result). So if there is a reasonable way to avoid that it's probably worth while.
https://github.com/ansible/galaxy_ng/issues/247#issuecomment-644983783 mentions a few vague ideas on approaches to handle this issue. In particular, the main #2 point there.
Gist is providing a way for the serializers get_href methods to use a url namespace (or specify url name explicitly) when the viewset classes have been subclassed (as galaxy_ng.app.api.v3.viewsets.collections.CollectionViewSet does).
-
There may be existing django or drf support for doing this but it isn't clear to me yet. (The 'content_app' attribute mentioned in https://github.com/ansible/galaxy_ng/issues/247#issuecomment-644983783 seems like it is intended for exactly this case, but I couldn't get it to work. But that is likely developer error on my part)
-
Maybe this is something drf-nested-routers / rest_framework_nested is meant to support?
Updated by bmbouter about 4 years ago
- Sprint/Milestone deleted (
0.4.0)
taking of 0.4.0 per check-in meeting w/ @galaxy_ng
Updated by pulpbot about 3 years ago
- Description updated (diff)
- Status changed from NEW to CLOSED - DUPLICATE