Your view(s) can only see the variables that you return from the controller, in your case mainly 1: form.
So your result view is not getting any variables from its controller. You have two options: 1) retrieve the values from the session directly in the view (you have been saving them) 2) retrieve the values from the session in the controller and return the variables needed in a dictionary Option 1 might look like this in the view: {{if (session.emp == 'EIA' and session.UC == 'CZA'....}} or initialize the vars without changing the ifs: {{emp = session.emp UC = session.UC ... }} {{if (emp == 'EIA' and UC == 'CZA' ... Option 2 is similar but in the controller: return {'emp': session.emp, 'UC': session.UC, ...} Denes. On Saturday, October 24, 2015 at 8:32:00 PM UTC-4, Arlindo Gomes Filho wrote: > > > Hi everybody, > > I’m beginner, trying to develop a code in which the user is asked to > answer three questions (presented in two sequential forms) and, based on > the combination of those answers the code (in the view “result”) is > supposed to present the user the one procedure among four available that > best apply to the situation. > > > The first form (LIC_ZON) is correctly redirecting to the second one, which > is also correctly redirecting to the view “result”. My problem is that it > seems my code in the view “result” is not processing the answers chosen by > the user and that are passed by the sessions. No matter the options > chosen by the user, only one and the same procedure is always presented in > the view (procedure four). I can't get what I'm missing. > > > > Thanks for any help. > > > Complete code in: https://github.com/argofix/Bungo > > > My contoller: > > > > def LIC_ZON(): form = SQLFORM.factory( Field('emp', label='Type of > license:', requires=IS_IN_SET(['EIA', 'SEIA', 'NALIC'])), Field('UC', > label='Type of zone:', requires=IS_IN_SET(['CZA', 'SZA', 'NAZA'])) ) if > form.process().accepted: session.flash = 'Option succesfully inserted!' > session.emp = form.vars.emp session.UC = form.vars.UC emp = > request.vars.emp UC = request.vars.UC if form.vars.UC == 'CZA': > redirect(URL('UCCZA')) if form.vars.UC == 'SZA': if form.vars.emp == 'EIA' > : redirect(URL('UCSZA3')) if form.vars.emp == 'SEIA': redirect(URL('UCSZA2 > ')) if form.vars.emp == 'NALIC': redirect(URL('UCNALIC')) if form.vars.UC > == 'NAZA': redirect(URL('UCNAZA')) return dict(form=form) def UCCZA(): > form = SQLFORM.factory( Field('uccza', label='Where is the activity > located?', requires=IS_IN_SET(['IUC', 'IZA', 'FZA'])) ) if > form.process().accepted: response.flash = 'Option succesfully inserted!' > session.uccza = form.vars.uccza uccza = request.vars.uccza redirect(URL(' > result')) return dict(form=form) def UCSZA3(): form = SQLFORM.factory( > Field('ucsza3', label='Where is the activity located?', requires= > IS_IN_SET(['IUC', 'ZPD3', 'FZPD3'])) ) if form.process().accepted: > response.flash = 'Option succesfully inserted!' session.ucsza3 = > form.vars.ucsza3 ucsza3 = request.vars.ucsza3 redirect(URL('result')) > return dict(form=form) def UCSZA2(): form = SQLFORM.factory( Field('ucsza2 > ', label='Where is the activity located?', requires=IS_IN_SET(['IUC', ' > ZPD2', 'FZPD2'])) ) if form.process().accepted: response.flash = 'Option > succesfully inserted!' session.ucsza2 = form.vars.ucsza2 ucsza2 = > request.vars.ucsza2 redirect(URL('result')) return dict(form=form) def > UCNALIC(): form = SQLFORM.factory( Field('ucnalic', label='Where is the > activity located?', requires=IS_IN_SET(['IUC', 'FUC'])) ) if form.process( > vars).accepted: response.flash = 'Option succesfully inserted!' > session.ucnalic = form.vars.ucnalic ucnalic = request.vars.ucnalic > redirect(URL('result')) return dict(form=form) def UCNAZA(): form = > SQLFORM.factory( Field('ucnaza', label='Where is the activity located?', > requires=IS_IN_SET(['IUC', 'FUC'])) ) if form.process().accepted: > response.flash = 'Option succesfully inserted!' session.ucnaza = > form.vars.ucnaza ucnaza = request.vars.ucnaza redirect(URL('result')) > return dict(form=form) def result(): return dict() > > > My view: > > > {{extend 'layout.html'}} <h1>Procedure you shoud apply</h1> <h2>{{if (emp > == 'EIA' and UC == 'CZA' and uccza == 'IUC') or (emp == 'EIA' and UC == > 'CZA' and uccza == 'IZA') or (emp == 'EIA' and UC == 'CZA' and uccza == > 'FZA') or (emp == 'SEIA' and UC == 'CZA' and uccza == 'IUC') or (emp == > 'SEIA' and UC == 'CZA' and uccza == 'FZA') or (emp == 'EIA' and UC == 'SZA' > and ucsza1 == 'IUC') or (emp == 'EIA' and UC == 'SZA' and ucsza1 == 'ZPD3') > or (emp == 'SEIA' and UC == 'SZA' and ucsza2 == 'IUC'):}} Apply procedure 1 > {{elif > (emp == 'SEIA' and UC == 'CZA' and uccza == 'IZA') or (emp == 'SEIA' and UC > == 'SZA' and ucsza2 == 'ZPD2'):}} Apply procedure 2 {{elif (emp == > 'NALIC' and UC == 'CZA' and uccza == 'IUC') or (emp == 'NALIC' and UC == > 'SZA' and ucnalic == 'IUC') or (emp == 'EIA' and UC == 'NAZA' and ucnaza == > 'IUC') or (emp == 'SEIA' and UC == 'NAZA' and ucnaza == 'IUC') or (emp == > 'NALIC' and UC == 'NAZA' and ucnaza == 'IUC'):}} Apply procedure 3 {{else:}} > Apply procedure 4{{pass}}</h2> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.