On Sat, 2011-08-13 at 16:51 -0700, kes wrote: > On Aug 13, 3:12 pm, Matt Feifarek <[email protected]> wrote: > > > I don't think that it should be anything special; they're just functions > > after all. > > > > So, something like this should work: > > > > def view1(request): > > if [something something]: > > return view2(request) > > [other code here] > > return Response("This is from view1") > > > > def view2(request): > > return Response("This is from view2") > > > Yes, that works with no problems, but it becomes a problem when the > called view was view_configed with a renderer: > > @view_config(route_name="foo", > renderer="foo.jinja2") > def foo_view(request): > return {"whereami" : "foo!"} > > > @view_config(route_name="bar") > def bar_view(request): > return foo_view(request) > > Calling foo_view from bar_view returns a dictionary, not a Response. > In order for bar_view to use this, it would have to know what renderer > to run it through. This piece of information (the renderer) would > need to be duplicated in both foo_view and bar_view. >
I'm afraid there's no API to do exactly what you want to do right now. There's "pyramid.view.render_view_to_response" but its API is broken; it's descended from a time when there was no URL dispatch and only traversal. There's "pyramid.config.Configurator.derive_view", but it doesn't help because you'd still have to repeat the renderer name when you call it. Suggestions for a good API for this purpose would be useful (not the obvious I just want to call the function and get a response; views can be methods and instances too, and it would have to account for that, and be able to retrieve the registration data for those too). - C -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
