Beispiel #1
0
    def __init__(self, code='', args={}):
        self.code = code

        if cherrypy.request.app:
            msg = self._get_translation(args)
        else:
            msg = _messages.get(code, code) % args

        pattern = "%s: %s" % (code, msg)
        Exception.__init__(self, pattern)
Beispiel #2
0
    def __init__(self, code='', args={}):
        self.code = code

        if cherrypy.request.app:
            msg = self._get_translation(args)
        else:
            msg = _messages.get(code, code) % args

        pattern = "%s: %s" % (code, msg)
        Exception.__init__(self, pattern)
Beispiel #3
0
    def __init__(self, code='', args={}):
        self.code = code

        if cherrypy.request.app:
            msg = self._get_translation(args)
        else:
            for key, value in args.iteritems():
                if isinstance(value, unicode):
                    args[key] = value.encode('utf-8')
            msg = _messages.get(code, code) % args

        pattern = "%s: %s" % (code, msg)
        Exception.__init__(self, pattern)
Beispiel #4
0
    def __init__(self, code='', args={}):
        self.code = code

        if cherrypy.request.app:
            msg = self._get_translation(args)
        else:
            for key, value in args.iteritems():
                if isinstance(value, unicode):
                    args[key] = value.encode('utf-8')
            msg = _messages.get(code, code) % args

        pattern = "%s: %s" % (code, msg)
        Exception.__init__(self, pattern)
Beispiel #5
0
    def __init__(self, code='', args={}):
        self.code = code

        for key, value in args.iteritems():
            if isinstance(value, unicode):
                continue

            # value is not unicode: convert it
            try:
                # In case the value formats itself to an ascii string.
                args[key] = unicode(str(value), 'utf-8')
            except UnicodeEncodeError:
                # In case the value is a KimchiException or it formats
                # itself to a unicode string.
                args[key] = unicode(value)

        if cherrypy.request.app:
            msg = self._get_translation()
        else:
            msg = _messages.get(code, code)

        msg = unicode(msg, 'utf-8') % args
        pattern = "%s: %s" % (code, msg)
        Exception.__init__(self, pattern)
Beispiel #6
0
    def __init__(self, code="", args={}):
        self.code = code

        for key, value in args.iteritems():
            if isinstance(value, unicode):
                continue

            # value is not unicode: convert it
            try:
                # In case the value formats itself to an ascii string.
                args[key] = unicode(str(value), "utf-8")
            except UnicodeEncodeError:
                # In case the value is a KimchiException or it formats
                # itself to a unicode string.
                args[key] = unicode(value)

        if cherrypy.request.app:
            msg = self._get_translation()
        else:
            msg = _messages.get(code, code)

        msg = unicode(msg, "utf-8") % args
        pattern = "%s: %s" % (code, msg)
        Exception.__init__(self, pattern)