Links can now be serialized by subclasses
Review Request #7333 — Created May 25, 2015 and submitted
The machinery for serializing links has been modified so that its
behvaiour can be changed by subclasses. Theget_link_serializer
method takes a field name and returns the appropriate serializing
function for the link. The default function isserialize_link
but
subclasses may provide aserialize_fieldname_link
method that will be
used instead.
Tested the
serialize_fieldname_link
behaviour with a resource. It
worked as intended.Ran unit tests.
- Change Summary:
-
Move serialize function finding into a method.
- Description:
-
~ The machinery for serializing links has now been moved into the
~ serialize_link
method, which can be overridden in a child~ WebAPIResource
class to change how links are serialized. If a~ resource only wants a specific link to be serialized differently, a ~ serialize_fieldname_link
method can be implemented that will override~ the default serialize_link
behaviour.~ The machinery for serializing links has been modified so that its
~ behvaiour can be changed by subclasses. The get_link_serializer
~ method takes a field name and returns the appropriate serializing ~ function for the link. The default function is serialize_link
but~ subclasses may provide a serialize_fieldname_link
method that will be~ used instead. - Commit:
-
ca322624e75e0089e8ead9f3ba3a920a5e82b3ae162de4f5d79d817a4379b6f7ed6edd1cfdcba205
- Diff:
-
Revision 2 (+27 -14)
- Change Summary:
-
PEP8
- Commit:
-
162de4f5d79d817a4379b6f7ed6edd1cfdcba20503d514a05efb7b76a8847767fc5c246717d7726c
- Diff:
-
Revision 3 (+27 -14)
- Commit:
-
03d514a05efb7b76a8847767fc5c246717d7726c91380acc425ccb5bacafb3551125e602a079708e
- Diff:
-
Revision 4 (+26 -13)