With ajax=False I don't need some javascripts on every page.
I can just add {{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}}
in layout.html, and on every page users can vote (for example),
because ajax=False passed vars of current request to LOAD. And I liked
it, because I can write some components, like voting, feedback,
some_switchers, and all of them would work without javascript and on
any of my new sites.
Now I have 1.97.1. I replaced lines 124 and 125 with
other_request.vars = Storage(vars)
other_request.get_vars = Storage(vars)
to avoid error. But all of my components doesn't work, because I
think, now vars of current request doesn't pass to LOAD with
ajax=False. So, I need to write some javascripts to make it work
again. But what about backward compatibility?
thx
On 2 июл, 20:21, Massimo Di Pierro <[email protected]> wrote:
> Can you explain to me why you prefer ajax=False to ajax=True? What
> advantages do you expect?
>
> On Jul 2, 1:28 am, LightOfMooN <[email protected]> wrote:
>
>
>
>
>
>
>
> > ajax=False is very important for me, so, I like 1.96 more than 1.97 :)
> > I use it at most interactive components, that can be displayed on the
> > all pages of site.
>
> > Just one example:
>
> > def voting_viewlet():
> > if not session.has_key('finished_votings'):
> > session.finished_votings = {}
> > if request.vars.get('vote', None):
> > active_voting =
> > db((db.voting.id==session['active_voting'])&(db.voting.status=='opened')).s
> > elect().first()
> > if active_voting and active_voting.id not in
> > session.get('finished_votings', []):
> > answers =
> > db(db.voting_answers.voting_id==active_voting.id).select()
> > show_results = False
> > if active_voting.multi:
> > answerlist = []
> > tmp = makelist(request.vars.answer)
> > for i in tmp:
> > answerlist.append(int(i))
> > valide_answers = list(set(get_ids(answers)) &
> > set(answerlist))
> > if valide_answers:
>
> > db(db.voting_answers.id.belongs(valide_answers)).update(count=db.voting_ans
> > wers.count
> > +1)
> > try:
>
> > session['finished_votings'].append(active_voting.id)
> > except:
> > session['finished_votings']=[active_voting.id]
> > show_results = True
> > else:
> > if request.vars.answer:
> > answer = int(request.vars.answer)
> > if answer in get_ids(answers):
>
> > db(db.voting_answers.id==answer).update(count=db.voting_answers.count
> > +1)
> > try:
>
> > session['finished_votings'].append(active_voting.id)
> > except:
>
> > session['finished_votings']=[active_voting.id]
> > show_results = True
> > if show_results:
> > voting =
> > db(db.voting.id==active_voting.id).select().first() or
> > redirect(URL('default','index'))
> > answers =
> > db(db.voting_answers.voting_id==voting.id).select(orderby=~db.voting_answer
> > s.count)
> > count = 0
> > if answers:
> > max = answers.first().count
> > for answer in answers:
> > count += answer.count
> > for answer in answers:
> > if count > 0:
> > answer.percent =
> > int(float(answer.count)*100/count)
> > answer.width = int(float(answer.count)*100/
> > max)
> > answer.color = getColor()
> > else:
> > answer.percent = 0
> > answer.width = 0
> > answer.color = getColor()
> > return response.render('voting/
> > voting_viewlet_results.html', dict(voting=voting, answers=answers,
> > count=count))
>
> > votings = db(db.voting.status=='opened').select()
> > finished_votings = session.get('finished_votings',[])
> > unfinished_votings = []
> > for voting in votings:
> > if voting.id not in finished_votings:
> > unfinished_votings.append(voting)
> > if unfinished_votings:
> > active_voting = unfinished_votings[random.randint(0,
> > len(unfinished_votings)-1)]
> > session['active_voting'] = active_voting.id
> > else:
> > active_voting = None
> > session['active_voting'] = None
>
> > if active_voting:
> > answers =
> > db(db.voting_answers.voting_id==active_voting.id).select(orderby=db.voting_
> > answers.id)
> > else:
> > answers = []
>
> > return dict(active_voting=active_voting, answers=answers)
>
> > On 2 июл, 04:51, Massimo Di Pierro <[email protected]> wrote:
>
> > > There are logic problems with ajax=False. Just use ajax=True. I am not
> > > sure ajax=False should be an option al all.
>
> > > On Jul 1, 11:45 am, LightOfMooN <[email protected]> wrote:
>
> > > > Thx, but I just disabled some components until the new stable version
> > > > of webpy :)
>
> > > > On 1 июл, 21:29, Anthony <[email protected]> wrote:
>
> > > > > That problem has been fixed in trunk, but looks like another problem
> > > > > may
> > > > > have been introduced. Try downloading trunk revision d4c2d8d15bb1 --
> > > > > that
> > > > > fixes the request.vars problem, but comes before the
> > > > > copy.copy(request)
> > > > > problem was introduced. Actually, maybe you could try the latest
> > > > > revision in
> > > > > trunk and see if the copy.copy(request) causes the same problem for
> > > > > you as
> > > > > it has for pbreit -- that might help diagnose the problem.
>
> > > > > Anthony
>
> > > > > On Friday, July 1, 2011 10:57:13 AM UTC-4, LightOfMooN wrote:
> > > > > > so, request has no vars storage
>
> > > > > > On 1 июл, 20:53, LightOfMooN <[email protected]> wrote:
> > > > > > > def voting_viewlet():
> > > > > > > return dict()
>
> > > > > > > works fine
>
> > > > > > > But if I try to check request.vars, it crashes:
>
> > > > > > > def voting_viewlet():
> > > > > > > if request.vars.vote:
> > > > > > > pass
> > > > > > > return dict()
>
> > > > > > > rises an error
>
> > > > > > > On 1 июл, 20:46, LightOfMooN <[email protected]> wrote:
>
> > > > > > > > Hello, just updated web2py to 1.97.1 and one of my sites
> > > > > > > > crashed with
> > > > > > > > the same problem:
> > > > > > > > {{=LOAD('voting', 'voting_viewlet', ajax=False)[0][0]}}
> > > > > > > > too bad
>
> > > > > > > > On 1 июл, 01:10, pbreit <[email protected]> wrote:
>
> > > > > > > > > Any ideas on this one? Has anyone else had problems with
> > > > > > LOAD(ajax=False) in
> > > > > > > > > trunk? I tried switching it to deepcopy and got same error. I
> > > > > > > > > also
> > > > > > tried
> > > > > > > > > putting it in a try/except but could not find anything. Could
> > > > > > > > > my
> > > > > > request
> > > > > > > > > have something funky in it?