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 #1203 (closed defect: fixed)

Opened 12 years ago

Last modified 10 years ago

testutil.call_with_request unusable with "raise redirect()"

Reported by: Felix.Schwarz Owned by: Chris Arndt
Priority: normal Milestone: 1.0.x bugfix
Component: TurboGears Version: 1.0b2
Severity: normal Keywords: needs review
Cc:

Description

Calls with testutil.call_with_request(method, request) will always fail if method() raises redirects (e.g. 'raise redirect("login")').

File "/home/fs/workspace/junkkiller/junkkiller/quarantine/controllers.py", line 28, in login

raise redirect(forward_url)

File "/usr/lib/python2.4/site-packages/turbogears/controllers.py", line 540, in redirect

raise cherrypy.HTTPRedirect(

File "/usr/lib/python2.4/site-packages/cherrypy/_cperror.py", line 90, in init

if cherrypy.response.version >= "1.1":

File "/usr/lib/python2.4/site-packages/cherrypy/init.py", line 43, in getattr

return getattr(childobject, name)

AttributeError?: 'Response' object has no attribute 'version'

The version attribute is normally set by cherrypy but call_with_request does not call these methods (which is okay!). In order to make call_with_request usable again, I propose adding the line 'cherrypy.serving.response.version = "1.1"' just below 'cherrypy.serving.response = _cphttptools.Response()' in testutil.call_with_request.

Attachments

response_version.patch Download (1.1 KB) - added by Felix.Schwarz 12 years ago.
updated patch: DummyRequest? is too simple, too
test_reponse.py Download (1.0 KB) - added by Felix.Schwarz 12 years ago.
some cleanup, removed wrong cherrypy.request assignments
dummy-request.diff Download (5.0 KB) - added by Chris Arndt 10 years ago.
Combined above two files into one patch and adapted it to work with latest 1.0 HEAD

Change History

Changed 12 years ago by Felix.Schwarz

updated patch: DummyRequest? is too simple, too

Changed 12 years ago by Felix.Schwarz

some cleanup, removed wrong cherrypy.request assignments

comment:1 Changed 12 years ago by Felix.Schwarz

Actually, I found that DummyRequest? is a bit too simple. The updated test case will reveal that the TurboGears version is lacking several important attributes/functions such as browser_url. This is fixed by the patch attached as DummyRequest? inherits from cherrypy's Request now.

comment:2 Changed 12 years ago by jorge.vargas

  • Component changed from unassigned to TurboGears
  • Milestone set to 1.1

comment:3 Changed 12 years ago by jorge.vargas

from the mailing list

Note that CP 3 has a dummy request object in the main thread
(actually, there's a single default object shared by all non-request
threads) that you can play with to your heart's content. Ditto for
Response.


Robert Brewer
System Architect
Amor Ministries

comment:4 Changed 12 years ago by alberto

  • Milestone changed from 1.1 to __unclassified__

Batch moved into unclassified from 1.1 to properly track progress on the later

comment:5 Changed 10 years ago by Chris Arndt

  • Keywords needs re-test added

Can somebody check if this is still an issue or if testutil in 1.1 has been fixed in the meantime? If yes, please move into the "1.0-bugfix" milestone.

comment:6 Changed 10 years ago by Chris Arndt

  • Owner changed from anonymous to Chris Arndt
  • Status changed from new to assigned
  • Keywords review added; re-test removed
  • Milestone changed from __unclassified__ to 1.0.x bugfix

I tested this with the latest (r5365) 1.0 branch and teh issue still exists. But things have changed a bit with regard to request handling since this ticket was opened, so I adapted the patch by enhancing DummyRequest a little more and merging test_response.py into the existing test_testutils.py module. Before I apply this, I would like to get some feed back on the validity of the patch.

Changed 10 years ago by Chris Arndt

Combined above two files into one patch and adapted it to work with latest 1.0 HEAD

comment:7 Changed 10 years ago by faide

This patch seems pretty good to me. Let's apply this so that it's present in 1.0.7

comment:8 Changed 10 years ago by Chris Arndt

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

Applied in r5385.

Note: See TracTickets for help on using tickets.