Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1706 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

Fix TG2 to work with WebOb exceptions on Python 2.4

Reported by: mramm Owned by: mramm
Priority: highest Milestone:
Component: TurboGears Version: trunk
Severity: normal Keywords:
Cc:

Description

Webob Request and Response objects are new-style classes. WebOb? Exceptions are also Response objects, with proper HTTP codes, and that causes trouble on Python 2.4.

WebOb? has an exception property on each of the Exception classes, so you can raise HTTPExeption('exception message').exception which will raise a generic HTTPException which is NOT a new style class (and therefore works on 2.4). And HTTPException also has an call method that points to the "Response object" part of the exception, so if you call the exception WSGI style, you'll get a response.

However TG2 and Pylons do more than just call the response, we also set headers, merge cookies, and otherwise make changes to the Response. And we don't want to have to do this in different ways on different versions of Python if we can at all help it.

The easiest way around this problem is to:

1) Always use .exception so it works on both 2.4 and 2.5 2) update WebOb? so that the HTTPException object proxies the full Response object interface, not just call

Change History

comment:1 Changed 11 years ago by mramm

  • Status changed from new to assigned

I've sent code to Ian Bicking, which accomplishes 2. And a patch to Ben to do 1 in pylons. But now I'm stuck making Redirect work properly in TG2 --- but I think we're getting very, very close on this one.

comment:2 Changed 11 years ago by mramm

Changes in TG2 and WebOb? seem to work. A minor change to pylons is required, and that should be in place sometime today.

--Mark Ramm

comment:3 Changed 11 years ago by mramm

  • Status changed from assigned to closed
  • Resolution set to fixed

Everything seems to be working, and that result has now been verified by several people on different platforms, so I'm marking this as closed. (finally!!!).

comment:4 Changed 11 years ago by anonymous

  • Milestone 2.0-preview-1 deleted

Milestone 2.0-preview-1 deleted

Note: See TracTickets for help on using tickets.