6
6
``X-Message-ID-Hash`` headers. Either of these values can be combined with
7
7
the message's ``List-Archive`` header to create a globally unique URI to the
8
8
message object in the internet facing interface of the message store. The
9
``X-Message-ID-Hash`` is the Base32 SHA1 hash of the ``Message-ID``.
9
``X-Message-ID-Hash`` is the base-32 SHA1 hash of the ``Message-ID``.
11
11
>>> from mailman.interfaces.messages import IMessageStore
12
12
>>> from zope.component import getUtility
13
13
>>> message_store = getUtility(IMessageStore)
15
If you try to add a message to the store which is missing the ``Message-ID``
16
header, you will get an exception.
15
A message with a ``Message-ID`` header can be stored.
18
17
>>> msg = message_from_string("""\
19
18
... Subject: An important message
19
... Message-ID: <87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp>
21
21
... This message is very important.
23
>>> message_store.add(msg)
24
Traceback (most recent call last):
26
ValueError: Exactly one Message-ID header required
28
However, if the message has a ``Message-ID`` header, it can be stored.
30
>>> msg['Message-ID'] = '<87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp>'
31
23
>>> x_message_id_hash = message_store.add(msg)
32
24
>>> print(x_message_id_hash)
33
25
AGDWSNXXKCWEILKKNYTBOHRDQGOX3Y35
97
89
================================
99
91
You delete a message from the storage service by providing the ``Message-ID``
100
for the message you want to delete. If you try to delete a ``Message-ID``
101
that isn't in the store, you get an exception.
103
>>> message_store.delete_message('nothing')
104
Traceback (most recent call last):
108
But if you delete an existing message, it really gets deleted.
92
for the message you want to delete.
110
94
>>> message_id = message['message-id']
111
95
>>> message_store.delete_message(message_id)