def __init__(self, routes=None, resources=None, middlewares=None,
                 render_factory=None, error_handler=None, **kwargs):
        self.debug = kwargs.pop('debug', None)
        self.slash_mode = kwargs.pop('slash_mode', S_REDIRECT)
        if kwargs:
            raise TypeError('unexpected keyword args: %r' % kwargs.keys())
        self.resources = dict(resources or {})
        resource_conflicts = [r for r in RESERVED_ARGS if r in self.resources]
        if resource_conflicts:
            raise NameError('resource names conflict with builtins: %r' %
                            resource_conflicts)
        try:
            self.middlewares = list(middlewares or [])
        except __HOLE__:
            # TODO: tmp message until 0.6 or so
            raise TypeError('expected an iterable for middlewares (as of '
                            'Clastic 0.4, middlewares and render_factory '
                            'swapped argument position)')
        check_middlewares(self.middlewares)
        self.render_factory = render_factory

        self.set_error_handler(error_handler)

        routes = routes or []
        self.routes = []
        self._null_route = NullRoute()
        self._null_route.bind(self)
        for entry in routes:
            self.add(entry)
dataset/ETHPy150Open mahmoud/clastic/clastic/application.py/BaseApplication.__init__