Skip to content

Commit ae9b769

Browse files
authored
Merge pull request #415 from gerrod3/base_url_setting
Add new setting to expose hostname for base_url
2 parents e28385d + 435f546 commit ae9b769

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

CHANGES/412.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added new setting ``PYPI_API_HOSTNAME`` that is used to form a distribution's ``base_url``. Defaults to the machine's FQDN.

pulp_python/app/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.contrib.postgres.fields import ArrayField, JSONField
55
from django.core.exceptions import ObjectDoesNotExist
66
from django.db import models
7-
from dynaconf import settings
7+
from django.conf import settings
88
from yarl import URL
99

1010
from pulpcore.plugin.models import (

pulp_python/app/serializers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import tempfile
44

55
from django.core.files.storage import default_storage as storage
6+
from django.conf import settings
67
from packaging.requirements import Requirement
78
from rest_framework import serializers
89

@@ -12,7 +13,6 @@
1213
from pulp_python.app import models as python_models
1314
from pulp_python.app.tasks.upload import DIST_EXTENSIONS, DIST_TYPES
1415
from pulp_python.app.utils import parse_project_metadata
15-
from pulp_python.app.urls import PYPI_API_HOSTNAME
1616

1717

1818
class PythonRepositorySerializer(core_serializers.RepositorySerializer):
@@ -54,7 +54,7 @@ class PythonDistributionSerializer(core_serializers.DistributionSerializer):
5454

5555
def get_base_url(self, obj):
5656
"""Gets the base url."""
57-
return f"{PYPI_API_HOSTNAME}/pypi/{obj.base_path}/"
57+
return f"{settings.PYPI_API_HOSTNAME}/pypi/{obj.base_path}/"
5858

5959
def validate(self, data):
6060
"""

pulp_python/app/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
import socket
2+
13
PYTHON_GROUP_UPLOADS = False
4+
PYPI_API_HOSTNAME = 'https://' + socket.getfqdn()

pulp_python/app/urls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import socket
21
from django.urls import path
32

43
from pulp_python.app.pypi.views import SimpleView, MetadataView, PyPIView, UploadView
54

65
PYPI_API_URL = 'pypi/<path:path>/'
7-
PYPI_API_HOSTNAME = 'https://' + socket.getfqdn()
86
# TODO: Implement remaining PyPI endpoints
97
# path("project/", PackageProject.as_view()), # Endpoints to nicely see contents of index
108
# path("search/", PackageSearch.as_view()),

0 commit comments

Comments
 (0)