<s> """<STR_LIT>""" <EOL> from google . appengine . api import mail <EOL> from google . appengine . ext import webapp <EOL> MAIL_HANDLER_URL_PATTERN = '<STR_LIT>' <EOL> BOUNCE_NOTIFICATION_HANDLER_URL_PATH = '<STR_LIT>' <EOL> class InboundMailHandler ( webapp . RequestHandler ) : <EOL> """<STR_LIT>""" <EOL> def post ( self ) : <EOL> """<STR_LIT>""" <EOL> self . receive ( mail . InboundEmailMessage ( self . request . body ) ) <EOL> def receive ( self , mail_message ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> @ classmethod <EOL> def mapping ( cls ) : <EOL> """<STR_LIT>""" <EOL> return MAIL_HANDLER_URL_PATTERN , cls <EOL> class InvalidBounceNotificationError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> class BounceNotificationHandler ( webapp . RequestHandler ) : <EOL> """<STR_LIT>""" <EOL> def post ( self ) : <EOL> """<STR_LIT>""" <EOL> self . receive ( BounceNotification ( self . request . POST ) ) <EOL> def receive ( self , bounce_notification ) : <EOL> pass <EOL> @ classmethod <EOL> def mapping ( cls ) : <EOL> """<STR_LIT>""" <EOL> return BOUNCE_NOTIFICATION_HANDLER_URL_PATH , cls <EOL> class BounceNotification ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , post_vars ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> self . __original = { } <EOL> self . __notification = { } <EOL> for field in [ '<STR_LIT:to>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:text>' ] : <EOL> self . __original [ field ] = post_vars [ '<STR_LIT>' + field ] <EOL> self . __notification [ field ] = post_vars [ '<STR_LIT>' + field ] <EOL> self . __original_raw_message = mail . InboundEmailMessage ( <EOL> post_vars [ '<STR_LIT>' ] ) <EOL> except KeyError , e : <EOL> raise InvalidBounceNotificationError ( e [ <NUM_LIT:0> ] ) <EOL> @ property <EOL> def original ( self ) : <EOL> return self . __original <EOL> @ property <EOL> def notification ( self ) : <EOL> return self . __notification <EOL> @ property <EOL> def original_raw_message ( self ) : <EOL> return self . __original_raw_message </s>
