Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite recursion in view lookup #1643

Closed
mmerickel opened this issue Apr 22, 2015 · 1 comment
Closed

infinite recursion in view lookup #1643

mmerickel opened this issue Apr 22, 2015 · 1 comment
Labels

Comments

@mmerickel
Copy link
Member

Reproducible example:

from pyramid.view import view_config, render_view_to_response

class Foo(object):
    pass

@view_config(route_name='trigger')
def trigger_view(request):
    print 'trigger view'
    return render_view_to_response(Foo(), request)

@view_config(context=Foo, renderer='json')
def foo_view(context, request):
    print 'foo view'
    return dict(success=False)

if __name__ == '__main__':
    from pyramid.config import Configurator
    from waitress import serve

    config = Configurator()
    config.add_route('trigger', '/')
    config.scan(__name__)
    app = config.make_wsgi_app()
    serve(app, host='127.0.0.1', port=7777)

Then:

python foo.py
curl http://localhost:7777/

The render_view_to_response(...) ends up finding trigger_view again and calling it, thus resulting in an infinite recursion.

The issues I see as I go through this:

  • The original request for / matches trigger. This results in request_iface = 'trigger_IRequest'.
  • The full SRO for request_iface is (<InterfaceClass pyramid.request.trigger_IRequest>, <InterfaceClass zope.interface.Interface>).
  • This does NOT include IRequest!!!
  • All SROs contain Interface at some point and thus this recursion may always be a risk unless we come up with a work around.
@mmerickel mmerickel added the bugs label Apr 22, 2015
@jenner
Copy link
Contributor

jenner commented Apr 22, 2015

Can confirm, pyramid.view.render_view_to_response(..) behaves completely different between 1.5.x and 1.6.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants