[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-08-11 Thread Val K
Yes! you're right, after installation pywin32 my test works properly! Thank you! P.S. I think that would be better to copy/paste that Attention from Overview to Session chapter and make it more *impressive* I suppose there are many people (like me) who have read an Overview once and never ag

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-08-11 Thread Anthony
Probably you are running web2py from source with your own Python installation and have not installed the pywin32 extension (which is required for file locking). Anthony On Monday, August 10, 2015 at 8:06:12 PM UTC-4, Val K wrote: > > As I see, the pro

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-08-10 Thread Val K
As I see, the problem is that ajax request (may be not ajax only) didn't wait for closing session file by another one and read/save data from/to it at any time! Lock did not work on my Win7 because , as I think, for Win it's one process. Request processing may be not pure parallel but fully asy

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-08-09 Thread Anthony
All responses within the same session are supposed to have the same session_id. The fact that all three Ajax requests can access the session doesn't necessarily mean they are being processed in parallel (the requests might still be completing one after another). It would be helpful if you could

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-08-09 Thread Val K
I realize your advice - no effect! I analyzed *session.connect* and found strange place at the biginig of *connect *definition: ... self._unlock(response) # - *unconditional unlock *session file witch have a name == response.session_id ... Then I changed definition of ajx_bug(): form=SQLFO

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-08-09 Thread Anthony
Does the problem occur only on the first page load of the session? If so, does the problem go away if you add the following line at the top of the many_ajx_form function: session.dummy_data = 'dummy data' If that's the case, then this is the same problem diagnosed in the original thread, w

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-08-08 Thread Val K
Hi! I have the same problem (twice submission). Here is my little test: #paste in default.py #!!! for pure test clean cookies before run!!! def print_form_keys(): ret=DIV(_class="container") for i in xrange(5): frm_k= '_formkey[%s]' % ('frm_id%s/create'%i) #- see html.FORM

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-19 Thread Anthony
Not sure what's going on. I also tried 2.11.2, though on Windows 8.1 x64 with Python 2.7.6. On Sunday, July 19, 2015 at 4:57:48 PM UTC-4, 黄祥 wrote: > > strange, in my local, > the behaviour make me submit twice for the form in first component (web2py > source version 2.11.2, python 2.7.8, windo

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-19 Thread 黄祥
strange, in my local, the behaviour make me submit twice for the form in first component (web2py source version 2.11.2, python 2.7.8, windows 7 x64), while i test the same app in pythonanywhere, it didn't make me submit twice for the form in first component (same like yours). already remove th

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-19 Thread Anthony
Sorry, I can't reproduce the problem with the attached app. When I go to /default/sale_order and select a product (a or b) from the list, set and quantity, and hit Submit, the form submits properly, and the table below is updated via Ajax with the values I submitted. I do not have to submit the

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-16 Thread 黄祥
1. *action :* after clean app, login, check the response.toolbar() *result *: no session value, no post_vars and no vars request 2. *action *: fill in the SQLFORM.factory, submit the button, check the response.toolbar() *result *: the checkout in second load component is not filled (no session

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-14 Thread Anthony
We need to see all the relevant code -- you haven't shown the link_callback code where the session is manipulated. Anyway, it's not the same problem as the one originally raised in this thread -- you don't have two simultaneous Ajax requests writing to the session (your Ajax request that affect

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-13 Thread 黄祥
sale_order_checkout use ajax callback to modify session.sale_order value, that is in the form in the HTML (not web2py form) the form that must submit twice is the one in the first component : sale_order_form which is generated via SQLFORM.factory. the form in second component is responsive (ajax

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-13 Thread Anthony
I may be missing something, but I still don't see where sale_order_checkout touches the session (it has a form in the HTML, but it is not a web2py form with a _formkey token, so it doesn't use the session). I don't think your problem is the same as the one discussed in this thread. Which of the

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-13 Thread 黄祥
already tried to write the dummy session data in (sale_order and sale_order_form) but still same (need submit twice), yet i got some bonus, traceback error said : AttributeError: 'str' object has no attribute 'items' *controllers/default.py* def sale_order(): session.sale_order = 'test'

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-13 Thread Anthony
Did you leave out some code, because the code you have shown for sale_order_checkout includes no form nor any writing to the session? The idea of the dummy data is just to write some nonsense data to the session in the *parent* function: def sale_order(): session.dummy = 'dummy data' ..

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-13 Thread 黄祥
hm, sorry, when i open in google groups it appears in web2py-users but in gmail i received it from web2py-developers. k, back to the problems. in web2py-users first report said : If the form has errors, the error messages are displayed after a second submit. So, I need to click two times the su

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-13 Thread Anthony
It's not clear this is the same problem, as you have only one form in a component, and the other component doesn't appear to save to the session. Read through the thread to repeat the diagnostics and see if you really are observing the same behavior (which implies the second component is saving

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2015-07-13 Thread 黄祥
i face the same situation, already use the formname and clear session. the form must submit twice to get it work. e.g. *controllers/default.py* def sale_order(): return locals() def sale_order_form(): form = SQLFORM.factory( Field('product', 'reference product', req

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-23 Thread Anthony
> What to do about this? I suppose one option would be to always create a >> new session file when a new session is started, even if the session is >> empty on the first request of the session (in the above example, an empty >> session file would be created on accessing the index page). Some a

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-23 Thread Niphlod
On Tuesday, April 23, 2013 4:00:11 AM UTC+2, Anthony wrote: > > The problem is that we made a change so that no session file is created at > all if this is a new session and the session remains empty. So, when the > index page is requested, no session file is created. Next, the form1 Ajax > re

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-23 Thread Neil
Thanks Niphlod & Anthony - I'm glad we finally got to the bottom of this. I thought I was going crazy for a while there! In the short term, I'll use Niphlod's trick of setting a dummy session variable to make sure the session is saved to disk. In the medium term, I vote for option 1 (always sa

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Anthony
The problem is that we made a change so that no session file is created at all if this is a new session and the session remains empty. So, when the index page is requested, no session file is created. Next, the form1 Ajax request comes in, and because there is no session file, there is nothing t

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Niphlod
umpf I can't understand why this is not working "ok". The problem lies indeed in the fact that one ajax request overwrites the session, if the session file is not there yet. I can only guess that the logic is failing to acquire a lock before creating the (new) file If a request has

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Niphlod
ok, behaviour confirmed on my pc too. PS: noticed that with def index(): session.hello = 'world' return dict() all works fine, every time. I'm debugging right now to see what's going on on the 2 ajax requests. On Monday, April 22, 2013 7:22:46 PM UTC+2, Neil wrote: > > I've been doing

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
I've been doing a little debugging. When the page loads, _try_store_in_file(self, request, response) in globals.py is called twice. The first time it saves formname1, and the second time it seems to overwrite the original file with formname2 (occasionally the order is reversed). How would a loc

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Anthony
If you are saving sessions in files, the session file should be locked by each request, so there shouldn't be any race conditions. However, if you are saving sessions in the db, you could get race conditions (e.g., both Ajax requests read the same empty session, then form1 saves its session wit

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
Good thought, but that doesn't seem to be a factor since it works in incognito after the first submit, and I can reproduce in regular mode. For some reason, on initial page load it is not saving both formkeys. Is it possible that there is a conflict when saving the the sessions file? i.e. both

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Niphlod
completely "out-of-side" observation (I'll make sure I get this tested once I get home to report the behaviour on my pc) are you sure that your "incognito-mode" browser accepts cookies ? -- --- You received this message because you are subscribed to the Google Groups "web2py-users" gro

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
A little more progress - I can now predict when the problem will occur server side, before hitting submit. This is what I do: 1) clear all my web2py session files 2) open an incognito brower 3) go to the page with multiple ajax forms 4) take a look at the new session file. If it looks like this:

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
Good suggestion - I think we may be getting somewhere. When it fails, the server is getting a '_formkey[formname2]' when submitting form 1. I'll try to dig a little deeper. On Monday, 22 April 2013 15:26:03 UTC+1, Anthony wrote: > > Not sure what's going on. In the browser, maybe use the develop

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Anthony
Not sure what's going on. In the browser, maybe use the developer tools to confirm what is being sent (i.e., session cookie, value of the hidden _formkey field). On the server, check that there is a "_formkey[formname1]" key in the session and that it matches the _formkey value submitted with t

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
My first submit failed on Mac (both Chrome and Safari). However, I can't get it to happen on Ubuntu. I can now reproduce in the following situations: - running web2py locally and remote - 2 server OSs (windows & linux) - 2 webservers (rocket & uwgsi/nginx) - 2 front-end OSs (windows

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
Wow, really! That's really frustrating... Nope, I never tried clearing cookies and then submitting. I always clear my history, shut down the browser, restart the browser, copy the URL, and then the first submit (sometimes) fails. What else about my system could lead to this behavior? I'm goin

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Anthony
> > 1) go to http://www.ai-therapy.com/ajax_test/ 2) enter something in Form 1, and press submit > 3) did it work *the first time*? (the second, and subsequent, submit > usually works for me) > 4) if I clear the cookies and restart the browser, the first submit fails > about 50% of the time. >

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
Just to clarify, I used the "new simple application" option with trunk (I didn't copy over the app from a previous version). Just to be 100% sure I also copied the web2py.js and web2py_ajax.html files over from the welcome app with no success. On Monday, 22 April 2013 14:53:28 UTC+1, Neil wrote

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
I didn't upgrade - when I ran locally I downloaded trunk from github and used that version with rocket. Same problem. On Monday, 22 April 2013 14:47:14 UTC+1, Anthony wrote: > > >> web2py.js is inside your app (in /appname/static/js), so it does not get > updated when you upgrade web2py. When yo

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Anthony
> > 1) I don't think I'm using an old web2py.js, unless it is accidentally > being packaged with the latest source. web2py.js is inside your app (in /appname/static/js), so it does not get updated when you upgrade web2py. When you upgrade web2py, you have to manually copy the new version of w

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
Note: it is still frustratingly unpredictable. I followed my own instructions 10 times before it happened again... On Monday, 22 April 2013 14:10:33 UTC+1, Neil wrote: > > 1) go to http://www.ai-therapy.com/ajax_test/ > 2) enter something in Form 1, and press submit > 3) did it work *the first ti

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
This is turning out to be an elusive one! Notes: 1) I don't think I'm using an old web2py.js, unless it is accidentally being packaged with the latest source. 2) weheh: Nope, no uploading involved - all the code is above. 3) I guessed it is related to the multiple forms issue since the behavior

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread weheh
I've done this before -- multiple ajax forms on one page -- and not had any issues. EXCEPT, I'm guessing from the names of your functions that you have an "upload" type field in there somewhere, or possibly in both forms. That is going to be an issue, since upload fields have to be treated speci

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Anthony
I had already tried something similar, and now I have tried your exact code, and I cannot reproduce the problem (running from trunk with Rocket on Windows 7). Is it possible you are using an old version of web2py.js? I've been playing around with it a bit more, and it seems to be the same > und

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
I've been playing around with it a bit more, and it seems to be the same underlying problem that Anthony described above. The question is: why doesn't the formname fix work for ajax components? On Monday, 22 April 2013 09:19:06 UTC+1, Neil wrote: > > Thanks for that. Unfortunately, there seems t

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-22 Thread Neil
Thanks for that. Unfortunately, there seems to be a little more to it. He is a minimal example (using web2py 2.4.6/rocket/windows, although the behavior is the same with other configurations). controllers/default.py: def index(): return dict() def f1(): val1 = "" form1 = FORM('For

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-21 Thread Anthony
Probably both forms have the same formname, either because they are both based on the same DAL table or because they are both SQLFORM.factory forms. To avoid the problem, assign unique formnames to each via .process(formname='myform1'), etc. This is discussed in the book: http://web2py.com/book

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-21 Thread Massimo Di Pierro
I opened an issue and will check later today: https://code.google.com/p/web2py/issues/detail?id=1457&thanks=1457&ts=1366557484 On Sunday, 21 April 2013 04:03:06 UTC-5, Neil wrote: > > I'm having this problem now - is there a trick to having two ajax forms on > one page? > > Basically, as above,

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2013-04-21 Thread Neil
I'm having this problem now - is there a trick to having two ajax forms on one page? Basically, as above, I have to hit submit twice for anything result. Has anyone successfully had 2+ ajax forms on the same page? On Wednesday, 21 July 2010 08:37:54 UTC+1, mdipierro wrote: > > will look into th

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2010-07-21 Thread mdipierro
will look into this.. it must be a JS issue. On Jul 20, 9:10 pm, ionel wrote: > Hello, > > I try to add two ajax forms into a page with something like this: > > {{=LOAD(url=URL(r=request,f='add_person.load'), ajax=True)}} > {{=LOAD(url=URL(r=request,f='add_image.load'), ajax=True)}} > > If the fo

[web2py] Re: Multiples ajax forms (with LOAD). It is possible?

2010-07-20 Thread ionel
Addition: only the first form has the problem. On Jul 20, 10:10 pm, ionel wrote: > Hello, > > I try to add two ajax forms into a page with something like this: > > {{=LOAD(url=URL(r=request,f='add_person.load'), ajax=True)}} > {{=LOAD(url=URL(r=request,f='add_image.load'), ajax=True)}} > > If the