Refactor #1555
closed
ModelSerializer translate functions should be public
Status:
CLOSED - CURRENTRELEASE
Description
ModelSerializer knows how to translate model fields when crafting responses, and also how to translate fields when parsing incoming requests. Unfortunately, it currently only exposes the latter behavior via its "translate_criteria" method. The "_translate" and "_translate_filters" methods are generally useful, and should be made public.
Note, it's not exclusively ID fields. We also had to change from to errata_from since 'from' is a reserved Python keyword. Because of that I suggest ID_FIELD.
Also note, there are at least two places where inbound data is also supposed to be transformed. See issue #1433 which described de-duplicating them and also links to the code which does the inbound translation.
Austin and I spoke about this, and I've also been dealing with the serializers a little more in-depth today, so I'll either reword this to match my updated thinking, or close it as a nonissue.
- Subject changed from Models with remapped id fields should know what field stores the ID to ModelSerializer translate functions should be public
- Description updated (diff)
This issue has been updated to reflect a more reasonable/less drastic first step in dealing with the issues raised in the original description.
- Status changed from NEW to ASSIGNED
- Assignee set to semyers
- Related to Task #1578: Incoming searches should be translated by the model added
I did a quick'n'dirty version of this in a recent commit[0] by publicizing the generally-useful private functions, so the work for this refactor consists mainly of fixing BaseSerializer and its subclasses to use the public method names and remove the private method names.
- Status changed from ASSIGNED to POST
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
- Platform Release set to 2.8.0
- Status changed from MODIFIED to 5
- Status changed from 5 to CLOSED - CURRENTRELEASE
Also available in: Atom
PDF
publicize useful serializer methods
As mentioned in the referenced issue, these serializer methods are generally useful and have been exposed as "public" in a previous commit. This makes that change formal by updating serializer internal references and tests to use the public methods.
fixes #1555 https://pulp.plan.io/issues/1555