예제 #1
0
파일: __init__.py 프로젝트: iofun/treehouse
    def get(self):
        """
            Get some quotes
        """
        quotes = PeopleQuotes()

        self.finish({"quote": quotes.get()})
예제 #2
0
파일: __init__.py 프로젝트: iofun/treehouse
    def let_it_crash(self, struct, scheme, error, reason):
        """
            Let it crash
        """

        str_error = str(error)
        error_handler = errors.Error(error)
        messages = []

        if error and "Model" in str_error:
            message = error_handler.model(scheme)

        elif error and "duplicate" in str_error:

            for name, value in reason.get("duplicates"):

                if value in str_error:

                    message = error_handler.duplicate(name.title(), value, struct.get(value))

                    messages.append(message)

            message = {"messages": messages} if messages else False

        elif error and "value" in str_error:
            message = error_handler.value()

        elif error is not None:
            logging.warning(str_error)

            logging.error(struct, scheme, error, reason)

            message = {"error": u"nonsense", "message": u"there is no error"}
        else:
            quotes = PeopleQuotes()

            message = {"status": 200, "message": quotes.get()}

        raise gen.Return(message)