~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/store.py

  • Committer: Curtis Hovey
  • Date: 2012-03-16 16:10:54 UTC
  • Revision ID: curtis.hovey@canonical.com-20120316161054-jk68i83kh81qm2vi
Store the body text only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
__metaclass__ = type
2
1
__all__ = [
3
 
    'make_json_message',
4
2
    'MemoryStore',
5
 
    'SUPPORTED_DISPLAY_TYPES',
6
 
    'SUPPORTED_ORDERS',
7
3
    ]
8
4
 
9
5
import email
11
7
from urlparse import parse_qs
12
8
 
13
9
from grackle.error import (
14
 
    ArchiveIdExists,
15
10
    ArchiveIdNotFound,
16
11
    MessageIdNotFound,
17
12
    UnparsableDateRange,
86
81
    def is_multipart(message):
87
82
        return isinstance(message['body'], list)
88
83
 
89
 
    def put_archive(self, archive_id, raw_archive=None):
90
 
        # XXX sinzui 2012-02-29: this needs to raise an error
91
 
        # if the th archive_id is invalid, or the raw archive is not mbox.
92
 
        if archive_id in self.message_archives:
93
 
            raise ArchiveIdExists()
94
 
        self.message_archives[archive_id] = []
95
 
 
96
84
    def put_message(self, archive_id, message_id, raw_message):
97
85
        # XXX sinzui 2012-02-29: this needs to raise an error
98
86
        # if the th archive_id is invalid, message_id is not base32
200
188
            }
201
189
        return response
202
190
 
203
 
    def hide_message(self, archive_id, message_id, query_string):
204
 
        """Change the visbility of a message in an archive.
 
191
    def hide_message(self, archive_id, query_string):
 
192
        """Return matching messages.
205
193
 
206
194
        :param archive_id: The archive to retrieve from.
207
195
        :param query_string: Contains 'parameters', which is a JSON-format
209
197
        """
210
198
        query = parse_qs(query_string)
211
199
        parameters = simplejson.loads(query['parameters'][0])
 
200
        message_id = parameters['message_id']
212
201
        hidden = parameters['hidden']
213
202
        messages = self.message_archives[archive_id]
214
203
        for message in messages: