[web2py] Re: Progress bars and session

2016-03-29 Thread chenlevy
So, I spend the best part of the day playing with your example but wasn't able to make it work. The best I have is that I see that before the form is submitted *getprogress* is called and return the expected value, but while progress is running it blocks the invocation of *getprogress* and the

Re: [web2py] Re: Progress bars and session

2016-03-23 Thread Alfonso Serra
Ill try to explain it here but this is gonna require a video tutorial: First there are several ways to achieve it. Although Anthony's suggestion (cache.ram) is optimal it didnt work on production, I dont know why cache.ram doesnt work on pythonanywhere. I got the progress bar working on

Re: [web2py] Re: Progress bars and session

2016-03-22 Thread chenlevy
Alfonso, so if you have a working progress bar, can you please post your complete solution (with a view and java-script) here? TIA, On Thursday, February 18, 2016 at 2:21:01 AM UTC+2, Alfonso Serra wrote: > > Omg it did work!. Thanks you very much Anthony, i owe you one. > > Console log: >

Re: [web2py] Re: Progress bars and session

2016-02-22 Thread Anthony
Try calling session.connect(). Anthony On Monday, February 22, 2016 at 4:18:10 PM UTC-5, Dan wrote: > > I've hit another obstacle using *session.forget(response)...* > > In the same controller / function where I'm using this > session.forget(response) for the progress bar (ajax) to work

Re: [web2py] Re: Progress bars and session

2016-02-22 Thread Dan
I've hit another obstacle using *session.forget(response)...* In the same controller / function where I'm using this session.forget(response) for the progress bar (ajax) to work properly, I cannot use any session variables (since these are "forgotten" as per the command above) ?! Is there a

Re: [web2py] Re: Progress bars and session

2016-02-21 Thread Dan
I am working on a progress bar and I have used the suggestion on this post to use *cache.ram* as the mechanism to update the client (via ajax call) while the controller (on the server) is still working. Using cache makes sense, since a global variable defined in a model such as db.py cannot be

Re: [web2py] Re: Progress bars and session

2016-02-17 Thread Alfonso Serra
Omg it did work!. Thanks you very much Anthony, i owe you one. Console log: progress -1 progress -1 main: 0 progress 0 main: 1 progress 1 main: 2 progress 2 main: 3 progress 3 main: 4 progress 4 -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) -

Re: [web2py] Re: Progress bars and session

2016-02-17 Thread Anthony
> return cache.ram.storage['message'][1] > Where did you see that as the way to access cached values? That is not the proper API. Note, cache.ram.storage is not initialized until cache.ram has been called at least once, so unless you have a cache.ram() somewhere prior in the same

Re: [web2py] Re: Progress bars and session

2016-02-17 Thread Alfonso Serra
Ive adapted the code to use cache.ram, but the docs about this mechanism is quite confusing, and i can't get it to work. There are several questions like, how to store simple values instead callables? what happens if i access a cache value after expiration? This is the code: def

Re: [web2py] Re: Progress bars and session

2016-02-17 Thread Anthony
Yes, I would say cache.ram might be a better approach. Also, keep in mind that although you might want to check every second or two, you don't have to update the progress variable after every single record insertion. For example, for a precision of 1%, just update the progress after every 300

Re: [web2py] Re: Progress bars and session

2016-02-17 Thread Alfonso Serra
> > > Perhaps you should update a field in some db table and use it instead of > session. > Please note that the end of this, is to create an ajax progress bar that indicates the numbers of records being inserted on a request. Although that might work as well, still it isnt good to read and

Re: [web2py] Re: Progress bars and session

2016-02-17 Thread Carlos Correia
On 17-02-2016 00:17, Alfonso Serra wrote: > Thanks Anthony, it does work. > > The hack is easy to implement, but to represent the insertion of 30k records > into the database, writing the session file and connecting 30k times might not > be optimal. > Perhaps you should update a field in some

[web2py] Re: Progress bars and session

2016-02-16 Thread Alfonso Serra
Thanks Anthony, it does work. The hack is easy to implement, but to represent the insertion of 30k records into the database, writing the session file and connecting 30k times might not be optimal. Theres a chapter about the Scheduler that may work for this. Ill read about it, it has

[web2py] Re: Progress bars and session

2016-02-16 Thread Anthony
Here's a hack that might work: def progress(): # when a form is submitted, change progress each second if request.post_vars: for i in range(5): session.progress = i # Write to the session file and unlock/close it.

[web2py] Re: Progress bars and session

2016-02-16 Thread Anthony
During a single request, the "session" object is just a copy of the session data stored in the session file. Any updates to the session during a request are not written back out to the session file until after the request has completed. So, in the progress() function, you are not updating the