The dot notation for session.vars.a is not going to work. It's true that session is a Python object and you can assign attributes to it, but vars is not a Python object. Thus you cannot assign attributes to it.
For this case, it would be simpler to just use something like session.user_input If for some reason you want to assign multiple values to session.vars, it could by a Python list or a dictionary. But first you have to initialize it, something like if 'vars' not in session: session.vars = {} # for a dictionary On Thursday, July 26, 2012 8:43:33 AM UTC-4, adohertyd wrote: > > Hope you guys can give me a hand here. I have two central functions in my > controller: index() and resultsDisplay() > > In index() the user enters a string into a form and it is assigned to > session.var.a > > session.var.a is passed to resultsDisplay() and it is processed. In the > resultsDisplay() view, I want the form from index() to be shown with the > user's string in it. I also will have a number of alternative suggestions > for the user. What I want is that if the user enters another term in the > form on the results page, or if the user clicks one of the supplied > suggestions, the resultsDisplay() function will restart, except that > instead of session.var.a being the form data from the index(), it will be > whatever the new value is. A great example of this is Google. If you type a > query in the main bar it gives you results. You notice that you've spelt > the query incorrectly. Google offers a suggestion, or the user has the > option of re-typing the query in the box and getting a new set of results. > How would I do this? Also, on a side note, how do I give the radio buttons > in my form a default value? > > *def index():* > > form = SQLFORM.factory( > Field('field_1','string', widget=SQLFORM.widgets.string.widget, > requires=IS_NOT_EMPTY()), > Field('field_2',requires=IS_IN_SET(('Yes','No')), widget=SQLFORM. > widgets.radio.widget), > submit_button='Go!') > if form.process().accepted: > session.term=request.vars.field_1 > session.aggregate=request.vars.field_2 > redirect(URL('resultsDisplay')) > else: > response.flash = 'please fill the form' > return dict(form=form) > > > *def resultsDisplay():* > > __function_1(session.term) > do some processing > __function_2(session.term) > do some processing > __function_3(session.term) > > > return locals() > > > *index.html:* > > {{=form.custom.begin}} > <div id="textBar">{{=form.custom.widget.field_1}}<br /> > {{=form.custom.submit}}</div> > <br /> > Choice: > <div>{{=form.custom.widget.field_2}}</div> > {{=form.custom.end}} > > > *resultsDisplay.html:* > * > * > #I want to put the form from index.html here > {{=DisplayResults_as per resultsDisplay function}} > #I want to put suggestions that, when clicked, will reload this page with > new result set. > > --