def delegate(self):
        path = self.request.path
        method = self.request.method
                
        for pattern, handler in self.routes:
            # Set defaults for handler
            handler.request = self.request
            handler.response = self.response
            
            if hasattr(handler, 'before'):
                handler.before()

            m = re.match('^' + pattern + '$', path)
            if m:
                args = m.groups()
                funcname = method.lower()
                try:
                    func = getattr(handler, funcname)
                except __HOLE__:
                    raise errors.HTTP_405("%s not allowed"%(method.upper()))

                output = func(*args)

                if hasattr(handler, 'after'):
                    handler.after()

                return output
                               
        raise errors.HTTP_404("Path %s not found"%(path))
dataset/ETHPy150Open nullism/pycnic/pycnic/core.py/WSGI.delegate