mikeckennedy/python-for-entrepreneurs-course-demos

raise.exc.HTTPFound() in BaseController.redirect() results in pyramid_debugtoolbar error.

kwan0xfff opened this issue · 2 comments

This is taken from example "04-applied-web/final_4_blue_yellow_app" and shows up in the console after attempting a valid "Register" of a new user.

This seems to be related to recent bugs reported at:

  • Pylons/pyramid_debugtoolbar#319
  • Pylons/pyramid_debugtoolbar#320
    The former seems similar to the problem here. The latter seems to be the root cause and a merged fix. One of the comments on the former is: "We don't recommend raising HTTPFound unless it truly is an exception..." Oh? It seems like this was fixed in pyramid-debugtoolbar 4.3? I have that version, but the problem persists.

Below is the trace I see on the console (with my home directory slightly doctored):

Serving on http://localhost:6543
Calling register via GET...
Calling register via POST...
Redirecting to account index page...
2017-12-30 17:07:45,926 ERROR [pyramid_debugtoolbar:257][waitress] Squashed Exception at 
http://localhost:6543/account/register
traceback url: http://localhost:6543/_debug_toolbar/34353230303932373834/exception
Traceback (most recent call last):
  File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/tweens.py", line 39, in excview_tween
    response = handler(request)
  File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/router.py", line 156, in handle_request
    view_name
  File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/view.py", line 642, in _call_view
    response = view_callable(context, request)
  File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/config/views.py", line 181, in __call__
    return view(context, request)
  File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/viewderivers.py", line 390, in attr_view
    return view(context, request)
  File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/viewderivers.py", line 368, in predicate_wrapper
    return view(context, request)
 File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/viewderivers.py", line 439, in rendered_view
    result = view(context, request)
  File "/Users/rick/web.env/lib/python3.6/site-packages/pyramid/viewderivers.py", line 124, in _class_requestonly_view
    response = getattr(inst, attr)()
  File "/Users/rick/Learn/Py4Entr/py4ent-demos/04-applied-web/final_4_blue_yellow_app/blue_yellow_app/controllers/account_controller.py", line 43, in register_post
    self.redirect('/account')
  File "/Users/rick/Learn/Py4Entr/py4ent-demos/04-applied-web/final_4_blue_yellow_app/blue_yellow_app/controllers/base_controller.py", line 23, in redirect
    raise exc.HTTPFound(to_url)
pyramid.httpexceptions.HTTPFound: The resource was found at

No resource was listed by last output line.

Thanks, Michael. Wasn't sure if I had a Pyramid bug that was going to stop me, or if there was a recommended alternate style.

--Rick