CORD-1594: Tag models with information about the leaf model, for casting
generic instances into specialized ones
Change-Id: I7b0f283b11380363742a284dc794bf3914e81fc9
diff --git a/lib/xos-genx/xosgenx/targets/django-split.xtarget b/lib/xos-genx/xosgenx/targets/django-split.xtarget
index a6ccab5..5260e85 100644
--- a/lib/xos-genx/xosgenx/targets/django-split.xtarget
+++ b/lib/xos-genx/xosgenx/targets/django-split.xtarget
@@ -45,6 +45,9 @@
# Generated methods
def save(self, *args, **kwds):
+ if not self.leaf_model_name:
+ self.leaf_model_name = "{{ m.name }}"
+
try:
self.__xos_save_base(*args, **kwds)
except AttributeError:
diff --git a/lib/xos-genx/xosgenx/targets/django.xtarget b/lib/xos-genx/xosgenx/targets/django.xtarget
index 400596c..e9a56ec 100644
--- a/lib/xos-genx/xosgenx/targets/django.xtarget
+++ b/lib/xos-genx/xosgenx/targets/django.xtarget
@@ -45,6 +45,9 @@
{% if m.name!='XOSBase' and 'Mixin' not in m.name %}
# Generated methods
def save(self, *args, **kwds):
+ if not self.leaf_model_name:
+ self.leaf_model_name = "{{ m.name }}"
+
try:
self.__xos_save_base(*args, **kwds)
except AttributeError:
diff --git a/lib/xos-genx/xosgenx/targets/service.xtarget b/lib/xos-genx/xosgenx/targets/service.xtarget
index a48abb7..80d90d6 100644
--- a/lib/xos-genx/xosgenx/targets/service.xtarget
+++ b/lib/xos-genx/xosgenx/targets/service.xtarget
@@ -61,6 +61,9 @@
# Generated methods
def save(self, *args, **kwds):
+ if not self.leaf_model_name:
+ self.leaf_model_name = "{{ m.name }}"
+
try:
self.__xos_save_base(*args, **kwds)
except AttributeError: