This is not a simple task, you can find info on how to use AJAX with web2py both in the cookbook and in the manual pdf, with lots of examples. Yield is powerful, but you have to know about generators and iterators to use it, with setting a small Popen buffer you might get away without them (although they would be more elegant) if you run in a separate thread. An example how to launch the automation in the background (and have the page complete without blocking):
from gluon.contrib.wsgihooks import PostConnectionTask,localposttasks class Automation (PostConnectionTask): def __init__ (self): PostConnectionTask.__init__ (self, request) def run (self): f=open("/tmp/automation-output", "w") f.write(fc.DecompressInput()) ... def automation(): Whatever-you-have-to-do-check-the-OKAY-cookie() localposttasks.append(Automation()) Whatever-you-have-to-do-delete-the-OKAY-cookie() return dict(msg='Automation started !') This way you'd probably read the automation-output file in the AJAX controller and return that. It would be best if your fc objects knew about the Popen buffers and they did the writing (so that you don't have to wait for the whole function to finish to have something in the output). On Feb 13, 12:25 pm, Cro <prah...@gmail.com> wrote: > Good day. > Thank you for all your responses. > It's seems that i have to AJAX the messages into the browser somehow, > but i have absolutely no idea how. > I am showing you the main template of any automation, maybe you can > understand what i am dealing with here. > > # Controller file > def index(): > "Check if automation can run" > content = "" > result = True > > import MyCheckFunctions as ck > if ck.CheckFoo1(): > content += "Input returned OKAY.<br>\n" > else: > content += "First check failed!<br>\n" > result = False > # > if ck.CheckFoo2(): > content += "Output returned OKAY.<br>\n" > else: > content += "Second check failed!<br>\n" > result = False > # > if result: > content += "<a href='automation'>Start automation!</a>" > Whatever-you-have-to-do-to-store-a-OKAY-cookie() > > return dict( content=XML(content) ) > > # Same file controller > def automation(): > "Run automation only if OKAY cookie is detected" > content = "" > > Whatever-you-have-to-do-check-the-OKAY-cookie() > # > import MyFunctions as fc > content += fc.DecompressInput() > content += fc.MoveFiles() # Takes quite some time to > finish. > content += fc.ProcessFiles() # Takes a lot of time to finish. > content += fc.CompressOutput() > content += fc.SendOutput() > # > Whatever-you-have-to-do-delete-the-OKAY-cookie() > > return dict( content=XML(content) ) > > So this is the basic of any automation. All functions are dumb, just > for the example. > I usually do stuff with batch files that i call when i need to perform > certain operations. > > So, can anyone suggest how to deal with AJAX thingy? Or 'yield' > thingy? (ive never used yield) > Thank you. :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---