Thanks Michael, thanks Carsten, that's just what I was looking for.
neurino On Aug 4, 7:46 pm, Carsten Senger <[email protected]> wrote: > --On Donnerstag, August 04, 2011 06:57:15 -0700 > > neurino <[email protected]> wrote: > > [...] > > > > > > > > > > > In a Pylons controller I could select which renderer use like this: > > > def my_view(self): > > c.form = Form(request, BasicSchema) > > if c.form.validate(): > > obj = form.bind(MYModel()) > > if **need more info**: > > c.form = Form(AdvancedSchema, obj=obj) > > if form.validate(): > > obj = form.bind(obj) > > else: > > return render('advanced_form.mako') > > **persist obj someway** > > redirect(...) > > return render('basic_form.mako') > > > In my Pyramid app I have: > > > config.add_route('new', '/new') > > config.add_view(my_view, route_name='new', > > renderer='basic_form.mako') > > > and in `basic_form.mako` according to a passed value I render the form > > one way or another: > > > %if step == 1: > > #render basic form > > %else: > > #render advanced form > > %endif > > > but it seems a bit ugly and cumbersome to me. > > > Any advice? > > You can implement the same pattern if you return a response object [1] and > don't have to specify the renderer in add_view(). Even if you specify > one it will be skipped if you return a response object, e.g. with > render_to_response(). > > ..Carsten > > [1] > <http://docs.pylonsproject.org/projects/pyramid/1.1/narr/templates.htm...> -- 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.
