Project

Profile

Help

Issue #7032

Provide a way for subclasses of pulp viewset that use serializers with href methods to override urls that are reversed

Added by alikins 3 months ago. Updated about 9 hours ago.

Status:
NEW
Priority:
Normal
Assignee:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Platform Release:
OS:
Triaged:
No
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:

Description

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?

History

#1 Updated by daviddavis 1 day ago

  • Sprint/Milestone set to 0.4.0

#2 Updated by bmbouter about 9 hours ago

  • Sprint/Milestone deleted (0.4.0)

taking of 0.4.0 per check-in meeting w/ @galaxy_ng

Please register to edit this issue

Also available in: Atom PDF