mailpipe: replace `respond` callback with exceptions.
authorW. Trevor King <wking@tremily.us>
Sat, 1 Sep 2012 19:25:58 +0000 (15:25 -0400)
committerW. Trevor King <wking@tremily.us>
Sat, 1 Sep 2012 19:25:58 +0000 (15:25 -0400)
commitcabf93c6a43b43ab2702123ffe332d1c15ce9738
tree60c4282274a1998993cda88dfc3a91c512fa7a47
parentf0ed7b324d9baf06768231118ba843752e8522f9
mailpipe: replace `respond` callback with exceptions.

Now mailpipe sub-functions will raise Response or InvalidMessage when
they want to respond to the incoming email.  This takes advantage of
Python's exception handling to avoid passing the `respond` callback
all over the place.  It also allows us consolidate error message
construction in `_get_error_response`, which will lead to both simpler
program logic and more consistent response messages.

Other changes to make this cleaner:

* Renamed functions in pygrader.email:
    _construct_email -> construct_email
    construct_email -> construct_text_email
* Pulled _get_assignment out of submission.run.
pygrader/email.py
pygrader/handler/__init__.py
pygrader/handler/get.py
pygrader/handler/submission.py
pygrader/mailpipe.py
pygrader/template.py