def dispatch(cls, router, msg):

        # spawn an instance of this handler, and stash
        # the low(er)-level router and message object
        inst = cls(router, msg)

        ### GET REPORTER
        try:
            cls.reporter = Reporter.objects.get(
                telephone_moh=msg.connection.identity, deactivated=False)
        except Exception, e:
            msg.respond(
                get_appropriate_response(DEFAULT_LANGUAGE_ISO='rw',
                                         message_type='sender_not_registered',
                                         destination=None,
                                         sms_report=None,
                                         sms_report_field=None)[1])
            return True
    def dispatch(cls, router, msg):

        # spawn an instance of this handler, and stash
        # the low(er)-level router and message object
        inst = cls(router, msg)

        ### GET REPORTER
        try:
            cls.reporter = Reporter.objects.get(telephone_moh=msg.connection.identity, deactivated=False)
        except Exception, e:
            msg.respond(
                get_appropriate_response(
                    DEFAULT_LANGUAGE_ISO="rw",
                    message_type="sender_not_registered",
                    destination=None,
                    sms_report=None,
                    sms_report_field=None,
                )[1]
            )
            return True
                    destination=None,
                    sms_report=None,
                    sms_report_field=None,
                )[1]
            )
            return True

        match = keyword.match(msg.text)
        if match is None:
            msg.respond(
                "%s, %s"
                % (
                    get_appropriate_response(
                        DEFAULT_LANGUAGE_ISO=cls.reporter.language,
                        message_type="empty_sms_report",
                        destination=None,
                        sms_report=None,
                        sms_report_field=None,
                    )[1],
                    get_appropriate_response(
                        DEFAULT_LANGUAGE_ISO=cls.reporter.language,
                        message_type="help",
                        destination=None,
                        sms_report=cls.sms_report,
                        sms_report_field=None,
                    )[1],
                )
            )
            return True

        # if any non-whitespace content was send after the keyword, send
class SMSReportKeywordHandler(BaseHandler):
    @classmethod
    def _keyword(cls):
        if hasattr(cls, "keyword"):
            prefix = r"^\s*(?:%s)(?:[\s,;:]+(.+))?$" % (cls.keyword)
            return re.compile(prefix, re.IGNORECASE)

    @classmethod
    def dispatch(cls, router, msg):

        # spawn an instance of this handler, and stash
        # the low(er)-level router and message object
        inst = cls(router, msg)

        ### GET REPORTER
        try:
            cls.reporter = Reporter.objects.get(
                telephone_moh=msg.connection.identity, deactivated=False)
        except Exception, e:
            msg.respond(
                get_appropriate_response(DEFAULT_LANGUAGE_ISO='rw',
                                         message_type='sender_not_registered',
                                         destination=None,
                                         sms_report=None,
                                         sms_report_field=None)[1])
            return True

        if cls.reporter is None:
            msg.respond(
                get_appropriate_response(DEFAULT_LANGUAGE_ISO="rw",
                                         message_type='sender_not_registered',
                                         destination=None,
                                         sms_report=None,
                                         sms_report_field=None)[1])
            return True

        keyword = cls._keyword()
        if keyword is None:
            msg.respond(
                get_appropriate_response(
                    DEFAULT_LANGUAGE_ISO=cls.reporter.language,
                    message_type='unknown_keyword',
                    destination=None,
                    sms_report=None,
                    sms_report_field=None)[1])
            return True

        try:
            cls.sms_report = SMSReport.objects.filter(
                keyword=msg.text.split()[0].upper())[0]
            cls.sms_report_keyword = cls.sms_report.keyword
        except Exception, e:
            #print e
            msg.respond(
                get_appropriate_response(
                    DEFAULT_LANGUAGE_ISO=cls.reporter.language,
                    message_type='unknown_keyword',
                    destination=None,
                    sms_report=None,
                    sms_report_field=None)[1])
            return True
            #print e
            msg.respond(
                get_appropriate_response(
                    DEFAULT_LANGUAGE_ISO=cls.reporter.language,
                    message_type='unknown_keyword',
                    destination=None,
                    sms_report=None,
                    sms_report_field=None)[1])
            return True

        match = keyword.match(msg.text)
        if match is None:
            msg.respond('%s, %s' %
                        (get_appropriate_response(
                            DEFAULT_LANGUAGE_ISO=cls.reporter.language,
                            message_type='empty_sms_report',
                            destination=None,
                            sms_report=None,
                            sms_report_field=None)[1],
                         get_appropriate_response(
                             DEFAULT_LANGUAGE_ISO=cls.reporter.language,
                             message_type='help',
                             destination=None,
                             sms_report=cls.sms_report,
                             sms_report_field=None)[1]))
            return True

        # if any non-whitespace content was send after the keyword, send
        # it along to the handle method. the instance can always find
        # the original text via self.msg if it really needs it.

        text = match.group(1) or " "