Skip to content

[from #5] Adding subject as a arg passed to self._handler in InboxServer #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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