Fixed update of WatcherObject fields on update
I this changeset, I fixed the issue whereby object auto fields are not being updated within the WatcherObject after an update. Change-Id: I7e65341b386a5c0c58c2109348e39e463cf2f668 Closes-Bug: #1641955
This commit is contained in:
@@ -146,8 +146,9 @@ class Action(base.WatcherPersistentObject, base.WatcherObject,
|
||||
of self.what_changed().
|
||||
"""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.update_action(self.uuid, updates)
|
||||
|
||||
db_obj = self.dbapi.update_action(self.uuid, updates)
|
||||
obj = self._from_db_object(self, db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
self.obj_reset_changes()
|
||||
|
||||
@base.remotable
|
||||
@@ -165,6 +166,9 @@ class Action(base.WatcherPersistentObject, base.WatcherObject,
|
||||
@base.remotable
|
||||
def soft_delete(self):
|
||||
"""Soft Delete the Audit from the DB"""
|
||||
self.dbapi.soft_delete_action(self.uuid)
|
||||
self.state = State.DELETED
|
||||
self.save()
|
||||
db_obj = self.dbapi.soft_delete_action(self.uuid)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
@@ -218,8 +218,9 @@ class ActionPlan(base.WatcherPersistentObject, base.WatcherObject,
|
||||
of self.what_changed().
|
||||
"""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.update_action_plan(self.uuid, updates)
|
||||
|
||||
db_obj = self.dbapi.update_action_plan(self.uuid, updates)
|
||||
obj = self._from_db_object(self, db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
self.obj_reset_changes()
|
||||
|
||||
@base.remotable
|
||||
@@ -253,6 +254,9 @@ class ActionPlan(base.WatcherPersistentObject, base.WatcherObject,
|
||||
for related_efficacy_indicator in related_efficacy_indicators:
|
||||
related_efficacy_indicator.soft_delete()
|
||||
|
||||
self.dbapi.soft_delete_action_plan(self.uuid)
|
||||
self.state = State.DELETED
|
||||
self.save()
|
||||
db_obj = self.dbapi.soft_delete_action_plan(self.uuid)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
@@ -255,7 +255,10 @@ class Audit(base.WatcherPersistentObject, base.WatcherObject,
|
||||
of self.what_changed().
|
||||
"""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.update_audit(self.uuid, updates)
|
||||
db_obj = self.dbapi.update_audit(self.uuid, updates)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
def _notify():
|
||||
notifications.audit.send_update(
|
||||
@@ -280,9 +283,12 @@ class Audit(base.WatcherPersistentObject, base.WatcherObject,
|
||||
@base.remotable
|
||||
def soft_delete(self):
|
||||
"""Soft Delete the Audit from the DB."""
|
||||
self.dbapi.soft_delete_audit(self.uuid)
|
||||
self.state = State.DELETED
|
||||
self.save()
|
||||
db_obj = self.dbapi.soft_delete_audit(self.uuid)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
def _notify():
|
||||
notifications.audit.send_delete(self._context, self)
|
||||
|
||||
@@ -215,8 +215,9 @@ class AuditTemplate(base.WatcherPersistentObject, base.WatcherObject,
|
||||
of self.what_changed().
|
||||
"""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.update_audit_template(self.uuid, updates)
|
||||
|
||||
db_obj = self.dbapi.update_audit_template(self.uuid, updates)
|
||||
obj = self._from_db_object(self, db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
self.obj_reset_changes()
|
||||
|
||||
@base.remotable
|
||||
@@ -234,4 +235,7 @@ class AuditTemplate(base.WatcherPersistentObject, base.WatcherObject,
|
||||
@base.remotable
|
||||
def soft_delete(self):
|
||||
"""Soft Delete the :class:`AuditTemplate` from the DB"""
|
||||
self.dbapi.soft_delete_audit_template(self.uuid)
|
||||
db_obj = self.dbapi.soft_delete_audit_template(self.uuid)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
@@ -123,7 +123,9 @@ class WatcherPersistentObject(object):
|
||||
the loaded object column by column in comparison with the current
|
||||
object.
|
||||
"""
|
||||
for field in self.fields:
|
||||
fields = (field for field in self.fields
|
||||
if field not in self.object_fields)
|
||||
for field in fields:
|
||||
if (self.obj_attr_is_set(field) and
|
||||
self[field] != loaded_object[field]):
|
||||
self[field] = loaded_object[field]
|
||||
|
||||
@@ -151,8 +151,9 @@ class Goal(base.WatcherPersistentObject, base.WatcherObject,
|
||||
of self.what_changed().
|
||||
"""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.update_goal(self.id, updates)
|
||||
|
||||
db_obj = self.dbapi.update_goal(self.uuid, updates)
|
||||
obj = self._from_db_object(self, db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
self.obj_reset_changes()
|
||||
|
||||
@base.remotable
|
||||
@@ -169,4 +170,7 @@ class Goal(base.WatcherPersistentObject, base.WatcherObject,
|
||||
@base.remotable
|
||||
def soft_delete(self):
|
||||
"""Soft Delete the :class:`Goal` from the DB"""
|
||||
self.dbapi.soft_delete_goal(self.uuid)
|
||||
db_obj = self.dbapi.soft_delete_goal(self.uuid)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
@@ -175,8 +175,9 @@ class ScoringEngine(base.WatcherPersistentObject, base.WatcherObject,
|
||||
of self.what_changed().
|
||||
"""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.update_scoring_engine(self.id, updates)
|
||||
|
||||
db_obj = self.dbapi.update_scoring_engine(self.uuid, updates)
|
||||
obj = self._from_db_object(self, db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
self.obj_reset_changes()
|
||||
|
||||
def refresh(self):
|
||||
@@ -191,4 +192,7 @@ class ScoringEngine(base.WatcherPersistentObject, base.WatcherObject,
|
||||
|
||||
def soft_delete(self):
|
||||
"""Soft Delete the :class:`ScoringEngine` from the DB"""
|
||||
self.dbapi.soft_delete_scoring_engine(self.id)
|
||||
db_obj = self.dbapi.soft_delete_scoring_engine(self.id)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
@@ -119,8 +119,9 @@ class Service(base.WatcherPersistentObject, base.WatcherObject,
|
||||
of self.what_changed().
|
||||
"""
|
||||
updates = self.obj_get_changes()
|
||||
self.dbapi.update_service(self.id, updates)
|
||||
|
||||
db_obj = self.dbapi.update_service(self.id, updates)
|
||||
obj = self._from_db_object(self, db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
self.obj_reset_changes()
|
||||
|
||||
def refresh(self):
|
||||
@@ -138,4 +139,7 @@ class Service(base.WatcherPersistentObject, base.WatcherObject,
|
||||
|
||||
def soft_delete(self):
|
||||
"""Soft Delete the :class:`Service` from the DB."""
|
||||
self.dbapi.soft_delete_service(self.id)
|
||||
db_obj = self.dbapi.soft_delete_service(self.id)
|
||||
obj = self._from_db_object(
|
||||
self.__class__(self._context), db_obj, eager=False)
|
||||
self.obj_refresh(obj)
|
||||
|
||||
Reference in New Issue
Block a user