CORD-1386: Port existing code to new data validation strategy
Change-Id: Id50d8cf76afa9f6cc7752b0d3cc451492a0a66f3
diff --git a/lib/xos-genx/xosgenx/targets/service.xtarget b/lib/xos-genx/xosgenx/targets/service.xtarget
index e70f0d6..a48abb7 100644
--- a/lib/xos-genx/xosgenx/targets/service.xtarget
+++ b/lib/xos-genx/xosgenx/targets/service.xtarget
@@ -26,6 +26,10 @@
{%- endif -%}
{% endfor %}
+{% for policy,error in xproto_validations(m.options) %}
+{{ xproto_fol_to_python_validator(policy, proto.policies[policy], m, error) }}
+{% endfor %}
+
{% endfor %}
{% for m in proto.messages %}
@@ -55,6 +59,18 @@
{% if file_exists(m.name|lower + '_model.py') -%}{{ include_file(m.name|lower + '_model.py') | indent(width=2)}}{%- endif %}
pass
+ # Generated methods
+ def save(self, *args, **kwds):
+ try:
+ self.__xos_save_base(*args, **kwds)
+ except AttributeError:
+ pass
+
+ {% for policy,error in xproto_validations(m.options) %}
+ policy_{{policy}}_validator(self, None)
+ {% endfor %}
+ super({{ m.name }}{{ legacy_tag }}, self).save(*args, **kwds)
+
{% if file_exists(m.name|lower+'_bottom.py') -%}{{ include_file(m.name|lower+'_bottom.py') }}{% endif %}
{% endfor %}
+++ models{{ legacy_tag }}.py