Add support for metadata instance classes #725
Merged
+154
−44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds the ability for custom class implementations to be tied to metadata instances of the same schema.
Schemas that contain the system-level property
metadata_class_name
will have instances containing their metadata properties of that class. These instances, which are subclasses ofMetadata
(enforced), can then override methodspost_load()
,pre_save()
andpre_delete()
to allow the implementations to adjust their values, perform actions on behalf of the instance, etc.The pre_save() method is called after validation, while post_load() is called prior to validation of the object against its schema. (Validation is not performed on deletes, so call order relative to validation is not applicable.)
Use of this feature is optional, but the metadata tests show how this can behave.
Developer's Certificate of Origin 1.1