Project

Profile

Help

Issue #4394

closed

Content serializer validate should ensure a saveable object

Added by mdellweg almost 6 years ago. Updated almost 5 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Quarter:

Description

This may be up for discussion:
In the current state, the content serializer family can validate content objects containing artifacts, but when valid, the user is supposed to pop off the `_artifact{,s}` field and create the `ContentArtifact` entities on his own.
I think, if the serializer said, an object is valid, a subsequent `save` without further parameters should just work.

In my approach, i tried to follow the example in [0]. This has the nice side-effect, that the plugin writer is not anymore concerned with handling the `ContentArtifacts` at all.

[0] https://www.django-rest-framework.org/api-guide/serializers/#writing-create-methods-for-nested-representations


Related issues

Related to RPM Support - Issue #4472: Relative_path error when uploading a fileCLOSED - CURRENTRELEASEdaviddavisActions
Actions #1

Updated by amacdona@redhat.com almost 6 years ago

  • Status changed from NEW to POST
  • Assignee set to mdellweg
Actions #2

Updated by CodeHeeler almost 6 years ago

  • Triaged changed from No to Yes
Actions #3

Updated by daviddavis almost 6 years ago

  • Tags Pulp 3, Pulp 3 RC Blocker added
Actions #4

Updated by daviddavis almost 6 years ago

  • Status changed from POST to MODIFIED

Solution was to move content artifact creation into the create method of serializers. There's a relative_path field now on SingleArtifactContentSerializer which plugins can set in the validate method. See pulp_file as an example:

https://github.com/pulp/pulp_file/pull/166

Actions #5

Updated by daviddavis over 5 years ago

  • Related to Issue #4472: Relative_path error when uploading a file added
Actions #6

Updated by daviddavis over 5 years ago

  • Sprint/Milestone set to 3.0.0
Actions #7

Updated by bmbouter over 5 years ago

  • Tags deleted (Pulp 3, Pulp 3 RC Blocker)
Actions #8

Updated by bmbouter almost 5 years ago

  • Status changed from MODIFIED to CLOSED - CURRENTRELEASE

Also available in: Atom PDF