On Dec 23, 2010, at 10:15 AM, Arun K.Rajeevan wrote:
> See following code, 
> I expect it to redirect to a url 
> 1) if user don't touch dropdown: 
> http://127.0.0.1:8000/init/default/search/<lang>/<word>?indx=0
>    but it shows http://127.0.0.1:8000/init/default/search/<lang>/<word>. Why 
> no vars?
> 2) if user altered dropdown: 
> http://127.0.0.1:8000/init/default/search/<lang>/<word>?indx=5
>  it's ok for first time. But if user select another item from select box 
> ?indx=['10'%2C+'5'] 
>  and if select another one ?indx=['19'%2C+"['10'%2C+'5']"]

Massimo:

Perhaps you can explain why indx is becoming a nested list, but setting that 
aside, if it *is* a list, I think the query string should be something like:

        ?indx=19&index=10&indx=5

That would require some additional logic in URL() for vars.

> 
> Where did I went wrong?
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
> In controller, before all functions, I've following,
> 
> options = [OPTION(row.full + '  - ' + row.short, _value=row.id) 
>         for row in db().select(db.languages.ALL, 
> cache=(cache.ram,3600)).sort(lambda a: a.full)]
> options.insert(0, OPTION('All Langauges', _value=0))
> search_form = FORM(LABEL('Search a word: ', _for='word', _id='word_label', 
> _name='word_label'),
>                     INPUT(_id='word', _name='word', requires=IS_NOT_EMPTY()), 
>                     SELECT(_onblur="var f = document.search_form; 
> f.indx.value = this.selectedIndex;", 
>                             _name='languages', _id='languages', 
> requires=IS_IN_DB(db,'languages.id'), *options),
>                     INPUT(_type='hidden', _name='indx', _id='indx', 
> value='0'),
>                     INPUT(_type="submit",_value="SEARCH"),
>                      _name='search_form')
> 
> # form verficaion logic on submission
> if search_form.accepts(request.vars, formname='search_form', hideerror=True):
>     lang = search_form.vars.languages
>     word = search_form.vars.word
>     indx = dict(indx = search_form.vars.indx)
>     redirect(URL(r=request, f='search', args=[lang, word], vars=indx))
> elif search_form.errors: #adding an element in option out of the db braked 
> prev mechanism. (ie., showing a flash. now that's done by show() itself.
>     lang = search_form.vars.languages
>     word = search_form.vars.word
>     redirect(URL(r=request, f='search', args=[lang, word]))
> else:
>     #page loads first time
>     pass
> 
> 


Reply via email to