Skip to content

Commit

Permalink
Merge pull request #6 from waawal/master
Browse files Browse the repository at this point in the history
[from #5] Adding subject as a arg passed to self._handler in InboxServer
  • Loading branch information
Kenneth Reitz committed May 11, 2012
2 parents b2d426c + 4b1c769 commit 4a13fec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Give your app an inbox easily::
inbox = Inbox()

@inbox.collate
def handle(to, sender, body):
def handle(to, sender, subject, body):
...

# Bind directly.
Expand All @@ -39,4 +39,4 @@ Installation

Installing Inbox.py is simple::

$ pip install inbox
$ pip install inbox
6 changes: 4 additions & 2 deletions inbox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

import argparse
from email.parser import Parser

import gevent
import gevent.monkey
Expand All @@ -25,8 +26,9 @@ def __init__(self, handler, *args, **kwargs):

def process_message(self, peer, mailfrom, rcpttos, data):
log.info('Collating message from {0}'.format(mailfrom))
log.debug(dict(to=rcpttos, sender=mailfrom, body=data))
return self._handler(to=rcpttos, sender=mailfrom, body=data)
subject = Parser().parsestr(data)['subject']
log.debug(dict(to=rcpttos, sender=mailfrom, subject=subject, body=data))
return self._handler(to=rcpttos, sender=mailfrom, subject=subject, body=data)


class Inbox(object):
Expand Down

0 comments on commit 4a13fec

Please sign in to comment.