How to read old property values in a _pre_put_hook
问题 I am trying to implement an ndb model audit so that all changes to properties are stored within each model instance. Here is the code of the _pre_put_hook I chose to implement that. def _pre_put_hook(self): # save a history record for updates if not (self.key is None or self.key.id() is None): old_object = self.key.get(use_cache=True) for attr in dir(self): if not callable(getattr(self, attr)) and not attr.startswith("_"): if getattr(self, attr) != getattr(old_object, attr): logging.debug(