# Path: kael/web_admin/exceptions.py
# OK = 10000
# class BaseError(Exception):
# class UnknownError(BaseError):
# class AuthError(BaseError):
# class InvalidTokenError(BaseError):
# class ArgumentError(BaseError):
# class MissArgumentError(ArgumentError):
# class NoFoundObjError(ArgumentError):
# class ObjExistError(ArgumentError):
# class InternalError(BaseError):
# class TimeoutError(InternalError):
# class UnsupportedError(ArgumentError):
# class WebProxyError(BaseError):
#     def __init__(self, description=None):
#     def __str__(self):
#     def __repr__(self):


import os
import pkgutil
import types
import simplejson as json
                import traceback
from datetime import date, datetime
from bson import ObjectId
from flask import Response, current_app, make_response, request, stream_with_context
from werkzeug.routing import BaseConverter
from kael.web_admin import exceptions
# import web_admin



class ListConverter(BaseConverter):
    def to_python(self, value):
        return value.split(',')

    def to_url(self, values):
        return ','.join(BaseConverter.to_url(value)
                        for value in values)


class RegexConverter(BaseConverter):
    def __init__(self, url_map, *items):
        super(RegexConverter, self).__init__(url_map)
        self.regex = items[0]


def json_converter(f):
    """Converts `dict`, list or mongo cursor to JSON.
    Creates `~flask.Response` object and sets headers.
    """

    def decorator(*args, **kwargs):
        try:
            result = f(*args, **kwargs)
        except Exception as e:
            raise e
        result = to_json({

# Path: kael/web_admin/exceptions.py
# OK = 10000
# class BaseError(Exception):
# class UnknownError(BaseError):
# class AuthError(BaseError):
# class InvalidTokenError(BaseError):
# class ArgumentError(BaseError):
# class MissArgumentError(ArgumentError):
# class NoFoundObjError(ArgumentError):
# class ObjExistError(ArgumentError):
# class InternalError(BaseError):
# class TimeoutError(InternalError):
# class UnsupportedError(ArgumentError):
# class WebProxyError(BaseError):
#     def __init__(self, description=None):
#     def __str__(self):
#     def __repr__(self):


# Path: kael/web_admin/common.py
import os
import pkgutil
import types
import simplejson as json
                import traceback
from datetime import date, datetime
from bson import ObjectId
from flask import Response, current_app, make_response, request, stream_with_context
from werkzeug.routing import BaseConverter
from kael.web_admin import exceptions

# import web_admin



class ListConverter(BaseConverter):
    def to_python(self, value):
        return value.split(',')

    def to_url(self, values):
        return ','.join(BaseConverter.to_url(value)
                        for value in values)


class RegexConverter(BaseConverter):
    def __init__(self, url_map, *items):
        super(RegexConverter, self).__init__(url_map)
        self.regex = items[0]


def json_converter(f):
    """Converts `dict`, list or mongo cursor to JSON.
    Creates `~flask.Response` object and sets headers.
    """

    def decorator(*args, **kwargs):
        try:
            result = f(*args, **kwargs)
        except Exception as e:
            raise e
        result = to_json({

            'status': exceptions.OK,