def _detach_db_obj(func):
 @functools.wraps(func)
 def decorator(self, *args, **kwargs):
  synthetic_changed = bool(self._get_changed_synthetic_fields())
  res = func(self, *args, **kwargs)
  if synthetic_changed:
   self.obj_context.session.refresh(self.db_obj)
  self.obj_context.session.expunge(self.db_obj)
  return res
 return decorator

def _detach_db_obj ( func ) : @ functools . wraps ( func ) def decorator ( self , * args , ** kwargs ) : synthetic_changed = bool ( self . _get_changed_synthetic_fields ( ) ) res = func ( self , * args , ** kwargs ) if synthetic_changed : self . obj_context . session . refresh ( self . db_obj ) self . obj_context . session . expunge ( self . db_obj ) return res return decorator
decorator to detach db_obj from the session .