Skip to content

Commit

Permalink
experimenting with some new interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Good committed May 21, 2015
1 parent 9947ea4 commit 861b4c2
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions pymap/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,30 @@ def __init__(self, name):
#: The name of the mailbox.
self.name = name

@asyncio.coroutine
def init(self):
"""For a new object, query the state of the mailbox backend such that
all attributes are appropriately set. Once this method returns, changes
from external sources will be caught by :meth:`.poll`.
:returns: The return value from this function is an arbitrary tracker
value will be passed into calls :meth:`.poll`, for use by the
backend.
"""
raise NotImplementedError

@asyncio.coroutine
def poll(self, tracker):
"""Checks the mailbox for any changes. This call should result in this
object's attributes being up-to-date.
:returns: Two-tuple of a new tracker value and a dictionary with
anything that has changed since the last :meth:`.poll`.
"""
raise NotImplementedError

@asyncio.coroutine
def get_messages_by_seq(self, seqs):
"""Get a list of :class:`Message` objects corresponding to given
Expand All @@ -184,7 +208,7 @@ def get_messages_by_uid(self, uids):
"""Get a list of :class:`Message` objects corresponding to the given
UIDs.
:param seqs: List of items, as described in
:param uids: List of items, as described in
:class:`~pymap.parsing.specials.SequenceSet`.
:returns: List of :class:`Message` objects.
Expand Down Expand Up @@ -264,17 +288,6 @@ def update_flags(self, messages, flag_list, mode='replace'):
"""
raise NotImplementedError

@asyncio.coroutine
def poll(self):
"""Checks the mailbox for any changes. This first time this is called
on the object, the ``exists`` and ``recent`` keys are always returned.
:returns: Dictionary with anything that has changed since the last
:meth:`.poll`.
"""
raise NotImplementedError


class MessageInterface(object):
"""Corresponds to a single message, as it exists in a single mailbox."""
Expand Down

0 comments on commit 861b4c2

Please sign in to comment.