Is there a *suggested* way to set a view renderer at runtime in
Pyramid?

What I need is to render, in the same view, a basic form then, if some
more info are needed (this is known by first form data), render
another form with already entered info as hidden field and more fields
to be filled.

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?

Thanks for your support

-- 
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.

Reply via email to