We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I need to select the model based on a value in the parent model.
'State': { 'Type': 'Task', 'Resource': 'TheParentValue', 'Parameters': { 'FieldsDependingOnParentValue': 'HowToDoThat?' }
Is that possible?
I tried using a claim_function but the data passed is from the same level and not from the parent.
The text was updated successfully, but these errors were encountered:
Couldn't you match on the parameters content?
from schematics.models import Model from schematics.types import serializable, StringType, IntType, PolyModelType state1 = { 'resource': 'StateType1', 'parameters': { 'x': '1', 'y': '2', } } state2 = { 'resource': 'StateType2', 'parameters': { 'z': 33, } } class ParametersType1(Model): x = StringType() y = StringType() class ParametersType2(Model): z = IntType() @classmethod def _claim_polymorphic(cls, data): return data.get('z') class StateClaim(Model): resource = StringType() parameters = PolyModelType([ParametersType1, ParametersType2]) s1 = StateClaim(state1) s2 = StateClaim(state2) print(s1, s1._data) print(s2, s2._data)
<StateClaim instance> {'resource': 'StateType1', 'parameters': <ParametersType1 instance>} <StateClaim instance> {'resource': 'StateType2', 'parameters': <ParametersType2 instance>}
Sorry, something went wrong.
No branches or pull requests
I need to select the model based on a value in the parent model.
Is that possible?
I tried using a claim_function but the data passed is from the same level and not from the parent.
The text was updated successfully, but these errors were encountered: