Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #600 (defect)

Opened 2 years ago

Last modified 2 years ago

InternalRedirect does double duty

Status: closed (fixed)

Reported by: fumanchu Assigned to: fumanchu
Priority: high Milestone: 3.0
Component: CherryPy code Keywords:
Cc:

InternalRedirect switches from one handler to another. For some time now (at least since [1400]) InternalRedirect has been schizophrenic, being asked to handle two very different needs:

  1. Those cases that require path_info to be rewritten. CherryPy 3 has no use cases for this; all have come entirely from user applications.
  2. Those cases that requre path_info to not be rewritten. This includes the virtual host tool and the XML-RPC tool. These should not rewrite path_info because that then affects systems like cherrypy.url, which expect the original path_info. See [1428] for an example of a test that fails when virtual_host is implemented using InternalRedirect.

My recommendation is that these two needs be met with separate features. The attached patch changes virtual host and xmlrpc, implementing them via dispatch wrapper functions instead of hooks + InternalRedirect. This leaves InternalRedirect free to meet only those cases which require path_info to be rewritten. There has been some discussion lately of dropping InternalRedirect, or possibly reimplementing it to use multiple Request objects in order to avoid some of the hook reentry madness described here. This patch allows that decision to proceed without losing any current CherryPy functionality.

Attachments

dispwrappers.patch (7.2 kB) - added by fumanchu on 11/13/06 19:06:58.
VHost and XML-RPC as dispatch wrappers
forward.patch (16.5 kB) - added by fumanchu on 11/15/06 13:23:17.
Patch which moves IR handling out of the Request object

Change History

11/13/06 19:06:58: Modified by fumanchu

  • attachment dispwrappers.patch added.

VHost and XML-RPC as dispatch wrappers

11/13/06 19:07:27: Modified by fumanchu

  • status changed from new to assigned.

11/15/06 13:18:09: Modified by fumanchu

The forward.patch goes a step further, moving the handling of InternalRedirect from the Request object out to the code which calls Request.run. See _cptree for the new redirect loop. This allows a single HTTP request to potentially create multiple Request obejcts to get the job done; the most important benefit of this is that each Request object can be properly finalized, including all hooks.

This patch also removes Request.redirections in favor of a (modpython-style) Request.prev attribute, which points to the previous Request object; adding the .next attribute might be helpful but was left out for now.

11/15/06 13:23:17: Modified by fumanchu

  • attachment forward.patch added.

Patch which moves IR handling out of the Request object

11/16/06 15:01:02: Modified by fumanchu

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in [1431] by applying the dispwrappers.patch. The forward.patch may be applied later.

Hosted by WebFaction

Log in as guest/cpguest to create tickets