+class StandaloneMessage(Message):
+ """An email message stored in the notmuch database.
+
+ This subclass of Message is used for messages that are retrieved from the
+ database directly and are not owned by a query.
+ """
+ @property
+ def alive(self):
+ if not self._parent.alive:
+ return False
+ try:
+ self._msg_p
+ except errors.ObjectDestroyedError:
+ return False
+ else:
+ return True
+
+ def __del__(self):
+ self._destroy()
+
+ def _destroy(self):
+ if self.alive:
+ capi.lib.notmuch_message_destroy(self._msg_p)
+ self._msg_p = None