se adiciona field.Function

FossilOrigin-Name: 45a288bc30ad9b25fed59cd01c89bd2f7632926083384a7853c3b753a4d7f95b
This commit is contained in:
bit4bit
2021-06-24 01:04:49 +00:00
parent 84996066fa
commit d78a429711
4 changed files with 78 additions and 0 deletions

View File

@@ -28,7 +28,18 @@ class ModelBase(object, metaclass=ModelMeta):
def __getitem__(self, key):
return self._xml_attributes[key]
def __before_xml__(self):
pass
def _hook_before_xml(self):
self.__before_xml__()
for field in self._fields.values():
if hasattr(field, '__before_xml__'):
field.__before_xml__()
def to_xml(self):
self._hook_before_xml()
tag = self.__name__
ns = ''
if self._namespace_prefix is not None: