no API break

This commit is contained in:
Christophe Benz 2010-03-11 11:49:27 +01:00 committed by Christophe Benz
commit e4846ff2a4
4 changed files with 13 additions and 4 deletions

View file

@ -25,5 +25,5 @@ class AuMBackend(Backend, ICapMessages, ICapMessagesReply):
def __init__(self, weboob):
Backend.__init__(self, weboob)
def iter_messages(self, thread=None):
def iterNewMessages(self, thread=None):
pass

View file

@ -26,7 +26,7 @@ class DLFPBackend(Backend, ICapMessages, ICapMessagesReply):
def __init__(self, weboob):
Backend.__init__(self, weboob)
def iter_messages(self, thread=None):
def iterNewMessages(self, thread=None):
articles_list = ArticlesList('newspaper')
for id, author, title in articles_list.iter_articles():
yield Message('threadid', id, title, author, signature='Bite bite bite bite', content='Content content\nContent content.')

View file

@ -73,10 +73,19 @@ class Message:
return self.new
class ICapMessages:
def iter_messages(self, thread=None):
def getNewMessages(self, thread=None):
"""
Get new messages from last time this function has been called.
@param thread [str] if given, get new messages for a specific thread.
@return [list] a list of Message objects.
"""
return [m for m in self.iterNewMessages(thread)]
def iterNewMessages(self, thread=None):
"""
Iterates on new messages from last time this function has been called.
@param thread [str] if given, get new messages for a specific thread.
@return [list] a list of Message objects.
"""

View file

@ -59,7 +59,7 @@ class Application(BaseApplication):
def process(self):
backends = self.weboob.getBackends()
for name, b in backends.iteritems():
for message in b.iter_messages():
for message in b.iterNewMessages():
self.send_email(name, message)
def send_email(self, backend_name, mail):