47
47
connection.request(method, url, body)
48
48
return connection.getresponse()
50
def message_url(self, archive_id, message_id, query):
51
"""Return the URL for a message
53
:param archive_id: The id of the archive to generate the URL for.
54
:param query: The query to use in the URL, as a dict.
56
path = '/archive/%s/%s' % (quote(archive_id), quote(message_id))
57
query_string = urlencode(query)
58
return urlunparse(('http', self.netloc, path, '', query_string, ''))
60
def _method_message(self, method, archive_id, message_id,
62
"""Perform an HTTP method on a message's URL."""
63
url = self.message_url(archive_id, message_id, query)
64
connection = self._get_connection()
65
connection.request(method, url, body)
66
return connection.getresponse()
68
50
def put_archive(self, archive_id, mbox=None):
69
51
"""Create an archive.
172
154
'hidden': hidden,
174
156
query = {'parameters': simplejson.dumps(parameters)}
175
response = self._method_message('POST', archive_id, message_id, query)
157
path = '%s/%s' % (archive_id, message_id)
158
response = self._method_archive('POST', path, query)
176
159
if response.status == httplib.BAD_REQUEST:
177
160
if response.reason == MessageIdNotFound.__doc__:
178
161
raise MessageIdNotFound