[web2py] Re: Select values from form and perform db search and display values on different page

2011-09-28 Thread Will

Thanks, that solved the problem,

didn't realize i wasn't saving in session, i was trying to transfer by
url following examples,
so i made following changes to code and now it is transferring values
correctly

redirect(URL('index',vars ={'bla' :request.vars.color}))

def index():
var = request.vars.bla
return dict(message=T('Hello World'),var = var)

On Sep 28, 10:13 am, Anthony  wrote:
> The way you're doing it, when you get to the index() function, 'blah' will
> be in request.vars.blah, not in session.vars (you never saved anything to
> the session). If you want it in the session, you'd have to do session.blah =
> request.vars.color in your formentry() function.
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, September 28, 2011 9:47:34 AM UTC-4, Will wrote:
>
> > Thanks for clearing up the displaying unique dropdown value code.
> > Anyone have any thoughts on how to take a select variable and display
> > those values from a table in the new url?  For instance I am getting
> > None in the bla variable on the index page.  After selecting my form
> > and redirecting there.
>
> > On Sep 28, 8:47 am, Anthony  wrote:
> > > On Wednesday, September 28, 2011 8:16:18 AM UTC-4, Will wrote:
>
> > > >     for row in ra:
> > > >         SA.add(row.color)
> > > >     ##ra = db().select(db.aa.color, distinct=True)
>
> > > >     ##form = SQLFORM.factory(SQLField('color', label='Select a
> > > > service'), requires=IS_IN_DB(db,'aa.color'))
>
> > > The above should work, but the 'requires' goes inside Field() -- also,
> > use
> > > Field instead of SQLField (they're the same, but the latter is
> > deprecated).
>
> > > Actually, since you've already got a DB table, you can just use SQLFORM()
>
> > > and specify the specific field you want to show via the 'fields'
> > argument.
> > > If you don't want to write to the DB, specify dbio=False in the
> > > form.accepts().
>
> > > >     form = SQLFORM.factory(
> > > >     Field('color', requires=IS_IN_SET(SA)))
> > > >     if form.accepts(request.vars, session):
> > > >         response.flash = 'form accepted'
> > > >         redirect(URL('index',vars ={'bla' :request.vars}))##I want to
> > > > take this variable and perform a search and return the values on
> > > > another page for instance index, does anyone see  a way to do that?
> > > > I've tried a few different formats
>
> > > The value of the 'color' field will be in request.vars.color and
> > > form.vars.color (they should be the same, unless the particular validator
>
> > > for the field happens to apply a transformation, which is not the case
> > > here).
>
> > > Anthony


[web2py] Re: Select values from form and perform db search and display values on different page

2011-09-28 Thread Anthony
The way you're doing it, when you get to the index() function, 'blah' will 
be in request.vars.blah, not in session.vars (you never saved anything to 
the session). If you want it in the session, you'd have to do session.blah = 
request.vars.color in your formentry() function.

Anthony

On Wednesday, September 28, 2011 9:47:34 AM UTC-4, Will wrote:
>
> Thanks for clearing up the displaying unique dropdown value code. 
> Anyone have any thoughts on how to take a select variable and display 
> those values from a table in the new url?  For instance I am getting 
> None in the bla variable on the index page.  After selecting my form 
> and redirecting there. 
>
> On Sep 28, 8:47 am, Anthony  wrote: 
> > On Wednesday, September 28, 2011 8:16:18 AM UTC-4, Will wrote: 
> > 
> > > for row in ra: 
> > > SA.add(row.color) 
> > > ##ra = db().select(db.aa.color, distinct=True) 
> > 
> > > ##form = SQLFORM.factory(SQLField('color', label='Select a 
> > > service'), requires=IS_IN_DB(db,'aa.color')) 
> > 
> > The above should work, but the 'requires' goes inside Field() -- also, 
> use 
> > Field instead of SQLField (they're the same, but the latter is 
> deprecated). 
> > 
> > Actually, since you've already got a DB table, you can just use SQLFORM() 
>
> > and specify the specific field you want to show via the 'fields' 
> argument. 
> > If you don't want to write to the DB, specify dbio=False in the 
> > form.accepts(). 
> > 
> > > form = SQLFORM.factory( 
> > > Field('color', requires=IS_IN_SET(SA))) 
> > > if form.accepts(request.vars, session): 
> > > response.flash = 'form accepted' 
> > > redirect(URL('index',vars ={'bla' :request.vars}))##I want to 
> > > take this variable and perform a search and return the values on 
> > > another page for instance index, does anyone see  a way to do that? 
> > > I've tried a few different formats 
> > 
> > The value of the 'color' field will be in request.vars.color and 
> > form.vars.color (they should be the same, unless the particular validator 
>
> > for the field happens to apply a transformation, which is not the case 
> > here). 
> > 
> > Anthony



[web2py] Re: Select values from form and perform db search and display values on different page

2011-09-28 Thread Will
Thanks for clearing up the displaying unique dropdown value code.
Anyone have any thoughts on how to take a select variable and display
those values from a table in the new url?  For instance I am getting
None in the bla variable on the index page.  After selecting my form
and redirecting there.

On Sep 28, 8:47 am, Anthony  wrote:
> On Wednesday, September 28, 2011 8:16:18 AM UTC-4, Will wrote:
>
> >     for row in ra:
> >         SA.add(row.color)
> >     ##ra = db().select(db.aa.color, distinct=True)
>
> >     ##form = SQLFORM.factory(SQLField('color', label='Select a
> > service'), requires=IS_IN_DB(db,'aa.color'))
>
> The above should work, but the 'requires' goes inside Field() -- also, use
> Field instead of SQLField (they're the same, but the latter is deprecated).
>
> Actually, since you've already got a DB table, you can just use SQLFORM()
> and specify the specific field you want to show via the 'fields' argument.
> If you don't want to write to the DB, specify dbio=False in the
> form.accepts().
>
> >     form = SQLFORM.factory(
> >     Field('color', requires=IS_IN_SET(SA)))
> >     if form.accepts(request.vars, session):
> >         response.flash = 'form accepted'
> >         redirect(URL('index',vars ={'bla' :request.vars}))##I want to
> > take this variable and perform a search and return the values on
> > another page for instance index, does anyone see  a way to do that?
> > I've tried a few different formats
>
> The value of the 'color' field will be in request.vars.color and
> form.vars.color (they should be the same, unless the particular validator
> for the field happens to apply a transformation, which is not the case
> here).
>
> Anthony


[web2py] Re: Select values from form and perform db search and display values on different page

2011-09-28 Thread Anthony
On Wednesday, September 28, 2011 8:16:18 AM UTC-4, Will wrote:
>
>
> for row in ra: 
> SA.add(row.color) 
> ##ra = db().select(db.aa.color, distinct=True) 
>
> ##form = SQLFORM.factory(SQLField('color', label='Select a 
> service'), requires=IS_IN_DB(db,'aa.color')) 
>

The above should work, but the 'requires' goes inside Field() -- also, use 
Field instead of SQLField (they're the same, but the latter is deprecated).

Actually, since you've already got a DB table, you can just use SQLFORM() 
and specify the specific field you want to show via the 'fields' argument. 
If you don't want to write to the DB, specify dbio=False in the 
form.accepts().
 

> form = SQLFORM.factory( 
> Field('color', requires=IS_IN_SET(SA))) 
> if form.accepts(request.vars, session): 
> response.flash = 'form accepted' 
> redirect(URL('index',vars ={'bla' :request.vars}))##I want to 
> take this variable and perform a search and return the values on 
> another page for instance index, does anyone see  a way to do that? 
> I've tried a few different formats 
>

The value of the 'color' field will be in request.vars.color and 
form.vars.color (they should be the same, unless the particular validator 
for the field happens to apply a transformation, which is not the case 
here).

Anthony