Browse files

Merge pull request #6 from waawal/master

[from #5] Adding subject as a arg passed to self._handler in InboxServer
  • Loading branch information...
2 parents b2d426c + 4b1c769 commit 4a13fec4cdc96d44d5f47fef16e107a5498cb3be @kennethreitz committed May 11, 2012
Showing with 6 additions and 4 deletions.
  1. +2 −2 README.rst
  2. +4 −2 inbox.py
View
4 README.rst
@@ -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.
@@ -39,4 +39,4 @@ Installation
Installing Inbox.py is simple::
- $ pip install inbox
+ $ pip install inbox
View
6 inbox.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import argparse
+from email.parser import Parser
import gevent
import gevent.monkey
@@ -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):

0 comments on commit 4a13fec

Please sign in to comment.