-
Notifications
You must be signed in to change notification settings - Fork 77
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
Ensure compatibility with CONTENT_ORIGIN=None #793
Conversation
pulp_python/app/utils.py
Outdated
@@ -315,7 +315,7 @@ def find_artifact(): | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If settings.CONTENT_ORIGIN
was None, wouldn't this result in a URL that starts with /
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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