~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Curtis Hovey
  • Date: 2012-03-17 21:04:24 UTC
  • Revision ID: curtis.hovey@canonical.com-20120317210424-v48z5vpdsgfxi0nd
do_PUT aways returns a empty list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
)
8
8
 
9
9
from grackle.error import (
 
10
    ArchiveIdExists,
10
11
    MessageIdNotFound,
11
12
    UnparsableDateRange,
12
13
    UnsupportedDisplayType,
30
31
    def archive_url(self, path, query):
31
32
        """Return the URL for an archive
32
33
 
33
 
        :param oath: The path to generate the URL for.
 
34
        :param path: The path to generate the URL for.
 
35
            Maybe be '', 'archive_id', or 'archive_id/message_id'
34
36
        :param query: The query to use in the URL, as a dict.
35
37
        """
36
38
        path = '/archive/%s' % quote(path)
54
56
        :param mbox: An optional mbox with messages to add to the new archive.
55
57
        """
56
58
        response = self._method_archive(
57
 
            'POST', '', {'archive_id': archive_id}, None)
 
59
            'PUT', archive_id, {}, None)
58
60
        response.read()
59
61
        if response.status == httplib.BAD_REQUEST:
 
62
            if response.reason == ArchiveIdExists.__doc__:
 
63
                raise ArchiveIdExists
60
64
            raise Exception('wtf')
61
65
        elif response.status == httplib.CREATED:
62
66
            return
73
77
        """
74
78
        path = '%s/%s' % (archive_id, key)
75
79
        response = self._method_archive(
76
 
            'POST', path, {}, file_obj.read())
 
80
            'PUT', path, {}, file_obj.read())
77
81
        response.read()
78
82
        if response.status == httplib.BAD_REQUEST:
 
83
            if response.reason == ArchiveIdExists.__doc__:
 
84
                raise ArchiveIdExists
79
85
            raise Exception('wtf')
80
86
        elif response.status == httplib.CREATED:
81
87
            return