This answers all my questions! Thanks so much! On Saturday, February 2, 2013 11:15:28 AM UTC-8, Niphlod wrote: > > > > On Saturday, February 2, 2013 7:06:18 PM UTC+1, Morgan Hein wrote: >> >> So I am using the trunk version, and finally got scheduling to run, >> however i'm encountering several problems (i'm assuming mostly due to my >> lack of understanding). >> >> Problem A) First off, for a while, when the workers ran the database that >> showed results worked. However now, workers run my script but there is no >> result in the scheduler_task table. I can see that the task has been run >> b/c the "times run" has been iterated by 1, but still no result. I tried >> deleting all rows, but none are being added. How can I troubleshoot this? >> > > I'm assuming what you mean is that you have no scheduler_run records while > you expect them. If that's the case, by default if the function doesn't > return a result, there is no scheduler_run record available. Just return > something on the function (a "return 0" is fine) if you want a record on > "None-returning" functions > > >> Problem B) What global application variables are available from tasks.py? >> I would like to access two objects, namely the database, as well as the >> folder/location of the run script (tasks.py). I could hardcode it but I >> feel that's bad practice. If possible i'd also love: >> > > Missing the "I'd also love" part, but to answer the question anything you > can access from web2py, except for session (well, you can but it would be a > bogus session), cache.ram (it's not "shared" with web2py's process, and it > gets resetted for every task) and request.env (because there isn't a normal > request associated with a task). Everything you can use on a web2py shell > (web2py.py -M -S yourapp) can be used inside a task of the scheduler . > > >> >> Problem C) And example or short snippet of adding an entry to a db from >> within a task, if it's any different from within the models themselves. >> Thanks! >> > > you can use the usual db.tablename.insert(columname=value) . The only > thing different in the scheduler vs the code you normally use is that you > must remember to do a db.commit() at the end of your function. web2py calls > db.commit() automatically when a request is completed, but the scheduler > does not. > >
-- --- 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/groups/opt_out.

