-
Notifications
You must be signed in to change notification settings - Fork 78
[PULP-715] WIP: Add JSON-based Simple API #956
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
base: main
Are you sure you want to change the base?
Conversation
16f7486
to
03e61c7
Compare
c7e19ec
to
6647217
Compare
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.
This PR looks like it is coming along well.
pulp_python/app/pypi/views.py
Outdated
def handle_exception(self, exc): | ||
# todo: fixes test_pull_through_filter? | ||
if isinstance(exc, (Http404, NotFound)): | ||
# Force JSON response since JSONRenderer is not in get_renderers() | ||
return JsonResponse({"detail": str(exc)}, status=404) | ||
return super().handle_exception(exc) |
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.
There's no reason the 404 has to be a JSON response. You could change the test to just check for the error string instead of expecting the result to be json.
PyPISimpleJSONRenderer(), | ||
] | ||
else: | ||
return [JSONRenderer(), BrowsableAPIRenderer()] |
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.
Does super().get_renders()
return these values?
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.
Yes
pulp_python/app/utils.py
Outdated
def write_simple_detail_json(project_name, project_packages): | ||
"""Writes the simple detail page in JSON format.""" | ||
files = [] | ||
for filename, url, sha256 in project_packages: |
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 make sense to change project_packages to a list of dictionaries, or namedtuples, and then modify the simple_detail template accordingly.
5f68a09
to
5ad38d9
Compare
closes #625