Skip to content

Commit 28eb280

Browse files
authored
Merge pull request #973 from jobselko/close_972
Update tasks to return JSON-serializable values
2 parents 7b1b409 + 7bca181 commit 28eb280

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGES/972.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated tasks to always return JSON-serializable value.

pulp_python/app/serializers.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,13 @@ def to_internal_value(self, data):
457457
"""Converts set to list."""
458458
return list(super().to_internal_value(data))
459459

460+
def to_representation(self, value):
461+
"""Converts set to list for JSON serialization."""
462+
result = super().to_representation(value)
463+
if isinstance(result, set):
464+
result = list(result)
465+
return result
466+
460467

461468
class PythonRemoteSerializer(core_serializers.RemoteSerializer):
462469
"""

pulp_python/app/tasks/publish.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pulpcore.plugin.util import get_domain
1010

1111
from pulp_python.app import models as python_models
12+
from pulp_python.app.serializers import PythonPublicationSerializer
1213
from pulp_python.app.utils import write_simple_index, write_simple_detail
1314

1415

@@ -36,6 +37,7 @@ def publish(repository_version_pk):
3637
write_simple_api(pub)
3738

3839
log.info(_("Publication: {pk} created").format(pk=pub.pk))
40+
pub = PythonPublicationSerializer(instance=pub, context={"request": None}).data
3941
return pub
4042

4143

0 commit comments

Comments
 (0)