import weakref
import notmuch2._base as base
+import notmuch2._config as config
import notmuch2._capi as capi
import notmuch2._errors as errors
import notmuch2._message as message
capi.lib.NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID]
if ret not in ok:
raise errors.NotmuchError(ret)
- msg = message.Message(self, msg_pp[0], db=self)
+ msg = message.StandaloneMessage(self, msg_pp[0], db=self)
if sync_flags:
msg.tags.from_maildir_flags()
return self.AddedMessage(
msg_p = msg_pp[0]
if msg_p == capi.ffi.NULL:
raise LookupError
- msg = message.Message(self, msg_p, db=self)
+ msg = message.StandaloneMessage(self, msg_p, db=self)
return msg
def get(self, filename):
msg_p = msg_pp[0]
if msg_p == capi.ffi.NULL:
raise LookupError
- msg = message.Message(self, msg_p, db=self)
+ msg = message.StandaloneMessage(self, msg_p, db=self)
return msg
@property
self._cached_tagset = weakref.ref(tagset)
return tagset
+ @property
+ def config(self):
+ """Return a mutable mapping with the settings stored in this database.
+
+ This returns an mutable dict-like object implementing the
+ collections.abc.MutableMapping Abstract Base Class.
+
+ :rtype: Config
+
+ :raises ObjectDestroyedError: if used after destroyed.
+ """
+ try:
+ ref = self._cached_config
+ except AttributeError:
+ config_mapping = None
+ else:
+ config_mapping = ref()
+ if config_mapping is None:
+ config_mapping = config.ConfigMapping(self, '_db_p')
+ self._cached_config = weakref.ref(config_mapping)
+ return config_mapping
+
def _create_query(self, query, *,
omit_excluded=EXCLUDE.TRUE,
sort=SORT.UNSORTED, # Check this default