~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Curtis Hovey
  • Date: 2012-02-29 23:55:28 UTC
  • Revision ID: curtis.hovey@canonical.com-20120229235528-7wphq02b2y9vt7ni
Implemented a partial put into the MemoryStore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        connection.request(method, url, body)
47
47
        return connection.getresponse()
48
48
 
 
49
    def put_archive(self, archive_id, mbox=None):
 
50
        """Create an archive.
 
51
 
 
52
        :param archive_id: The archive id.
 
53
        :param mbox: An optional mbox with messages to add to the new archive.
 
54
        """
 
55
        response = self._method_archive(
 
56
            'POST', '', {'archive_id': archive_id}, None)
 
57
        response.read()
 
58
        if response.status == httplib.BAD_REQUEST:
 
59
            raise Exception('wtf')
 
60
        elif response.status == httplib.CREATED:
 
61
            return
 
62
        else:
 
63
            raise Exception('!!')
 
64
 
49
65
    def put_message(self, archive_id, key, file_obj):
50
66
        """Put a message into an archive.
51
67
 
54
70
            the message.
55
71
        :param file_obj: The raw text of the message, as a file.
56
72
        """
 
73
        path = '%s/%s' % (archive_id, key)
57
74
        response = self._method_archive(
58
 
            'POST', archive_id, {'key': key}, file_obj.read())
 
75
            'POST', path, {}, file_obj.read())
59
76
        response.read()
60
77
        if response.status == httplib.BAD_REQUEST:
61
78
            raise Exception('wtf')