| 34 | |
| 35 | |
| 36 | class AppError(Exception): |
| 37 | |
| 38 | def __init__(self, message, *args): |
| 39 | if isinstance(message, bytes): |
| 40 | message = message.decode('utf8') |
| 41 | str_args = () |
| 42 | for arg in args: |
| 43 | if isinstance(arg, webob.Response): |
| 44 | body = arg.body |
| 45 | if isinstance(body, bytes): |
| 46 | if arg.charset: |
| 47 | arg = body.decode(arg.charset) |
| 48 | else: |
| 49 | arg = repr(body) |
| 50 | elif isinstance(arg, bytes): |
| 51 | try: |
| 52 | arg = arg.decode('utf8') |
| 53 | except UnicodeDecodeError: |
| 54 | arg = repr(arg) |
| 55 | str_args += (arg,) |
| 56 | message = message % str_args |
| 57 | Exception.__init__(self, message) |
| 58 | |
| 59 | |
| 60 | class CookiePolicy(http_cookiejar.DefaultCookiePolicy): |
no outgoing calls
searching dependent graphs…