On Sat, Aug 13, 2011 at 11:28 PM, Chris McDonough <[email protected]> wrote: > 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.
In that case, you can put the common code in a support method and call it from both views. I do that in Pylons sometimes, to prepare and render a form. -- Mike Orr <[email protected]> -- 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.
