def forward(cls, controller, action=None, params=None): ''' Forward the current request to the given action ''' action = action if action else "index" controller_inst = cls.instances[controller] if not controller_inst: cls.send_error(404, "Controller %s does not exist" % controller) try: action_meth = getattr(controller_inst, action) Logger.info("Forwarding to %s > %s with params = %s" % (controller, action, params)) return action_meth(**params) except AttributeError: cls.send_error(404, "%s/%s does not exist" % (controller, action)) except BaseException, e: Logger.error("Error while forwarding to %s > %s" % (controller, action), e) cls.send_error(500)
def redirect(cls, path, params=None): ''' Redirect the current request to the given path ''' url = BaseController._make_url(path, params) Logger.info("Redirecting to %s" % url) cherrypy.lib.cptools.redirect(url, False)