Open jackqu7 opened 8 years ago
I totally lost momentum with this branch but will be picking it up again next week. The TODO list I ended with was
nested_role
nested_role
nested_roles
test get_nested_role_for(serialize)
test with nested_role(role='')
test with nested_role(serialize_role='')
test with Nested(seralize_role='')
get_mapper_session
test get_nested_role_for(marshal)
test with nested_role(role='')
test with nested_role(marshal_role='')
test with Nested(marshal_role='')
get_mapper_session
get_mapper_session
with new role optIt really just needs a solid test which we're going to facilitate by taking the branch for a test run by updating our mappers in the Vizibl API code base.
Description
Roles provide user of Kim with a powerful way to control what fields should be included when marshaling or serialzing a Mapper. The ability to specify a role on a nested field has been available since v1 but the existing functionality only offers so much.
This proposal outlines new functionality that would allow users to specify the name of roles attached to a Nested field from inside Role definitions on other Mappers. We will also offer greater control over how Nested fields are processed by allowing users to set specific serialize and marshal roles.
Targeting Nested field roles
So the
user@basic
syntax results in the nested mapper using the 'basic' role. Theuser@basic
Role may also specify a role for a nested field too. The Nested fields would be processed the same way all the way down the chain.Different Serialize and Marshal roles for Nested fields.
It's quite common that you wan't to allow different fields when serializing data to those permitted when marshaling. This feature will add two new properties to the
NestedFieldOpts
-The new Nested roles syntax will allow users to specify different roles for serilaizing and marshaling
Deciding which role to use when processing a Nested field will flow something like the following:
Conclusion
We feel this feature is going to add a huge amount of value to Kim.
Nested
is already one of the best features Kim offers. Providing more options for configuring how they work will hopefully lead to some great use cases.We would love to hear any feedback anyone has on this feature. We wan't to make sure we get it right for everyone. If you have any suggestions or even just want to let us know you like the proposed approach then please don't hesitate.
Questions
When specifying marhsal and serialize roles using the new nested role syntax should they be provided separately (as seen in the example) or should we consider another option?
Another option that we considered was specifying the role in the following form:
user@{role_name} OR serialize:{role_name},marshal:{role_name}
We might also consider using an object over a string in the Role definition.
whitelist('name', nested('field_name', role='X', 'serialize='X', marshal='Y'), 'foo', ...)