'Set handler and config for the current request.'

def __call__(self, path_info):

    request = cherrypy.serving.request
    (resource, vpath) = self.find_handler(path_info)
    if resource:
        avail = [m for m in dir(resource) if m.isupper()]
        if (('GET' in avail) and ('HEAD' not in avail)):
            avail.append('HEAD')
        avail.sort()
        cherrypy.serving.response.headers['Allow'] = ',    '.join(avail)
        meth = request.method.upper()
        func = getattr(resource, meth, None)
        if ((func is None) and (meth == 'HEAD')):
            func = getattr(resource, 'GET', None)
        if func:
            if hasattr(func, '_cp_config'):
                request.config.update(func._cp_config)
            vpath = [x.replace('%2F', '/') for x in vpath]
            request.handler = LateParamPageHandler(func, *vpath)
        else:
            request.handler = cherrypy.HTTPError(405)
    else:
        request.handler = cherrypy.NotFound()
