~barry/mailman/lp1423756

« back to all changes in this revision

Viewing changes to src/mailman/model/docs/messagestore.rst

  • Committer: Barry Warsaw
  • Date: 2015-01-05 01:20:33 UTC
  • mfrom: (7264.4.66 py3)
  • Revision ID: barry@list.org-20150105012033-zdrw9c2odhpf22fz
Merge the Python 3 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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``.
10
10
 
11
11
    >>> from mailman.interfaces.messages import IMessageStore
12
12
    >>> from zope.component import getUtility
13
13
    >>> message_store = getUtility(IMessageStore)
14
14
 
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.
17
16
 
18
17
    >>> msg = message_from_string("""\
19
18
    ... Subject: An important message
 
19
    ... Message-ID: <87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp>
20
20
    ...
21
21
    ... This message is very important.
22
22
    ... """)
23
 
    >>> message_store.add(msg)
24
 
    Traceback (most recent call last):
25
 
    ...
26
 
    ValueError: Exactly one Message-ID header required
27
 
 
28
 
However, if the message has a ``Message-ID`` header, it can be stored.
29
 
 
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
================================
98
90
 
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.
102
 
 
103
 
    >>> message_store.delete_message('nothing')
104
 
    Traceback (most recent call last):
105
 
    ...
106
 
    LookupError: nothing
107
 
 
108
 
But if you delete an existing message, it really gets deleted.
 
92
for the message you want to delete.
109
93
 
110
94
    >>> message_id = message['message-id']
111
95
    >>> message_store.delete_message(message_id)