Ensure compatibility with CONTENT_ORIGIN=None#793
Conversation
pulp_python/app/utils.py
Outdated
| content_artifact = content.contentartifact_set.first() | ||
| artifact = find_artifact() | ||
| origin = settings.CONTENT_ORIGIN.strip("/") | ||
| origin = settings.CONTENT_ORIGIN.strip("/") if settings.CONTENT_ORIGIN else "" |
There was a problem hiding this comment.
If settings.CONTENT_ORIGIN was None, wouldn't this result in a URL that starts with /?
There was a problem hiding this comment.
It might be better to do something more along the lines of:
components = [prefix, base_path, content.filename]
if settings.CONTENT_ORIGIN:
components.insert(0, settings.CONTENT_ORIGIN.strip("/"))
...Which is the same way domain is handled more or less
There was a problem hiding this comment.
Or skip the .insert() and instead just build the list component by component.
components = []
if settings.CONTENT_ORIGIN:
components.append(settings.CONTENT_ORIGIN.strip("/"))
components.append(prefix)
if domain:
components.append(domain.name)
components.append(base_path)
components.append(content.filename)Which is probably simplest
There was a problem hiding this comment.
Ok I updated it to try to match what I did in pypi/views, basically try the CONTENT_ORIGIN else assume same fqdn and use PYPI_API_HOSTNAME, else set to empty string and hope the client interacting with the pypi API can handle relative urls.
Backport to 3.13: 💚 backport PR created✅ Backport PR branch: Backported as #796 🤖 @patchback |
Ensure compatibility with CONTENT_ORIGIN=None (cherry picked from commit 58653af)
…8d961dfd179e3ddc5be908490449bb/pr-793 [PR #793/58653afd backport][3.13] Ensure compatibility with CONTENT_ORIGIN=None
I forgot to include this in my 3.70 compat PR (woops). Going to need to backport this to 3.13