OK, scratch option #3.
On Sunday, September 20, 2015 at 9:34:00 AM UTC-4, Yoel Benitez Fonseca
wrote:
>
> As Anthony suggested in the workarounds:
>
> --
>
> city_widget = SQLFORM.widgets.autocomplete(request, db.city.name,
> id_field=db.city.id)
> city_widget.url = URL(args=request.args, vars=request.get_vars)
> db.person.city.widget = city_widget
> --
>
> turn to another problem, this is the content of request.vars for the
> callback from autocomplete:
>
> <Storage {'step': '1?_autocomplete_city_name=xx'}>
>
> It should be:
>
> <Storage {'step': '1' , '_autocomplete_city_name': 'xx'}>
>
> As you can see, autocomplete just add his parameters to the url
> assuming there are no other.
>
> 2015-09-20 9:01 GMT-04:00, Yoel Benitez Fonseca <[email protected]>:
> > Thank's Antony for the replay, i'll create the issue.
> >
> > The error in the code come from my adaptation of the real code to the
> > example posted in my original question.
> >
> > The reason I ask is because I have already taken account of these
> > three possible workarounds and i think we can do better.
> >
> > 2015-09-19 16:09 GMT-04:00, Anthony <[email protected]>:
> >> It won't always be desirable to preserve the original query string
> >> because
> >> the Ajax callback is not really requesting the original parent page but
> >> instead merely using the original action to access the autocomplete
> >> functionality. However, it would probably be a good idea to add an
> option
> >> to the autocomplete widget allowing the query string to be preserved,
> so
> >> you should submit a github issue about this (link back to this thread).
> >>
> >> For now, though, there are three possible workarounds:
> >>
> >> 1. Because the URL args are preserved, you can put the step in a URL
> >> arg
> >>
> >> instead of a "step" variable in the query string.
> >> 2. You can store the step in the session rather than in the URL (not
> >> good for bookmarking).
> >> 3. You can manipulate the widget after it has been instantiated
> >> (haven't
> >>
> >> tried it, but I think it should work):
> >>
> >> city_widget = SQLFORM.widgets.autocomplete(request,
> db.city.name,
> >> id_field=db.city.id)
> >> city_widget.url = URL(args=request.args, vars=request.get_vars)
> >> db.person.city.widget = city_widget
> >>
> >> Also, note that there is an error in your code -- you are assigning the
> >> widget to db.person.city rather than to db.person.city.widget.
> >>
> >> Anthony
> >>
> >> On Saturday, September 19, 2015 at 11:05:52 AM UTC-4, Yoel Benitez
> >> Fonseca
> >> wrote:
> >>>
> >>> hi! i have been struggling with a annoying bug, i got a this in a
> >>> controller:
> >>>
> >>> ---
> >>> def some_function():
> >>> if not request.vars.step:
> >>> redirect(URL('some_function', vars=dict(step=1)))
> >>> # ----
> >>> # a lot of stuff in the middle
> >>> # ----
> >>> if request.vars.step = '3':
> >>> db.person.city = SQLFORM.widgets.autocomplete(request,
> >>> db.city.name, id_field=db.city.id)
> >>> form = SQLFORM.factory(db.person):
> >>> if form.process().accepted:
> >>> # do some stuff
> >>> pass
> >>> # more stuff...
> >>> ---
> >>>
> >>> The problem is that the autocomplete callback overwrite anything in
> >>> request.vars and only left his own parameter _autocomplete_city_name,
> >>> is this the intended behavior ? i mean for me it have more sense that
> >>> the autocomplete callback add what it need and leave the others things
> >>> in place.
> >>>
> >>> --
> >>> Msc. Yoel Benítez Fonseca
> >>> Especialista en TI
> >>> http://redevil.cubava.cu/
> >>> Tel.: (53 32)284701
> >>>
> >>
> >> --
> >> 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 [email protected].
> >> For more options, visit https://groups.google.com/d/optout.
> >>
> >
> >
> > --
> > Msc. Yoel Benítez Fonseca
> > Especialista en TI
> > http://redevil.cubava.cu/
> > Tel.: (53 32)284701
> >
>
>
> --
> Msc. Yoel Benítez Fonseca
> Especialista en TI
> http://redevil.cubava.cu/
> Tel.: (53 32)284701
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.