<s> """<STR_LIT>""" <EOL> import logging <EOL> from google . appengine . api import xmpp <EOL> from tipfy import RequestHandler <EOL> class BaseHandler ( RequestHandler ) : <EOL> """<STR_LIT>""" <EOL> def message_received ( self , message ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def post ( self , ** kwargs ) : <EOL> try : <EOL> self . xmpp_message = xmpp . Message ( self . request . form ) <EOL> except xmpp . InvalidMessageError , e : <EOL> logging . error ( '<STR_LIT>' , <EOL> e [ <NUM_LIT:0> ] ) <EOL> return self . app . response_class ( '<STR_LIT>' ) <EOL> return self . message_received ( self . xmpp_message ) <EOL> class CommandHandlerMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def unhandled_command ( self , message ) : <EOL> """<STR_LIT>""" <EOL> message . reply ( '<STR_LIT>' ) <EOL> def text_message ( self , message ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def message_received ( self , message ) : <EOL> """<STR_LIT>""" <EOL> if message . command : <EOL> handler_name = '<STR_LIT>' % ( message . command , ) <EOL> handler = getattr ( self , handler_name , None ) <EOL> if handler : <EOL> handler ( message ) <EOL> else : <EOL> self . unhandled_command ( message ) <EOL> else : <EOL> self . text_message ( message ) <EOL> return self . app . response_class ( '<STR_LIT>' ) <EOL> class CommandHandler ( CommandHandlerMixin , BaseHandler ) : <EOL> """<STR_LIT>""" <EOL> pass </s>
