~unity-2d-team/unity-2d/Shell-MultiMonitor

« back to all changes in this revision

Viewing changes to grackle/server/model.py

  • Committer: William Grant
  • Date: 2012-01-22 06:41:06 UTC
  • Revision ID: william.grant@canonical.com-20120122064106-6at8ool919624m0z
Let the HTTP client decide count and order (to an extent).

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
            'subject': message['subject'],
102
102
            }
103
103
 
104
 
    def get_messages(self, archive_uuid):
 
104
    def get_messages(self, archive_uuid, count, order):
 
105
        if order in ("date", "-date"):
 
106
            reversed = order[0] == '-'
 
107
        else:
 
108
            raise AssertionError("Unsupported order.")
105
109
        ids = self.archive_messages.get(
106
 
            archive_uuid, column_count=10, column_reversed=True).values()
 
110
            archive_uuid, column_count=count,
 
111
            column_reversed=reversed).values()
107
112
        messages = self.messages.multiget(ids)
108
113
        return [self._format_message(messages[id]) for id in ids]