[web2py] Re: Several questions - Scheduler Related

2013-02-02 Thread Morgan Hein
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Several questions - Scheduler Related

2013-02-02 Thread Morgan Hein
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?

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:

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!

I'm really enjoying the flow of web2py, I hope that someone can help out 
with this!

`M

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Adding a scheduled task using the scheduler results in db error.

2013-02-02 Thread Morgan Hein
Massimo,

Wow that's customer support. Thanks for the quick reply!

However I am using 2.3.2, which is what is listed as the stable version. Do 
I need to download the experimental to get the scheduler to work?

Also, is it possible for me to just delete the old tables, replace web2py, 
and it will auto-create the new tables again?

Thanks!

`M

On Friday, February 1, 2013 8:14:19 PM UTC-8, Massimo Di Pierro wrote:
>
> You have an older version of the scheduler (and web2py). Your scheduler 
> tables have a field called "output" This field was renamed "run_output".
> This is because some database engines consider "output" a reserved keyword.
>
> Massimo
>
> On Friday, 1 February 2013 22:10:48 UTC-6, Morgan Hein wrote:
>>
>> Howdy!
>>
>> I have been following the video tutorial to create a schedule task. 
>>
>> Inside the bottom of the task to be run I have:
>>
>> def main():
>> o = MarketReader()
>> o.run()
>> 
>> from gluon.scheduler import Scheduler
>> Scheduler(db,dict(update_market=main))
>>
>>
>> When I browse back to the database management, I receive the following 
>> error:
>>
>> TICKET ID
>>
>> 127.0.0.1.2013-02-01.19-58-07.6e66c0a0-a0fa-49e0-b6b6-70ddb741fbeb
>>  invalid table/column name "output" is a 
>> "ALL" reserved SQL keywordVERSIONweb2py™(2, 3, 2, datetime.datetime(2012, 
>> 12, 17, 15, 3, 30), 'stable')PythonPython 2.7.3: /usr/bin/python
>>
>> Traceback (most recent call last):
>>   File "/home/johnnyfive/Downloads/web2py/gluon/restricted.py", line 212, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/johnnyfive/Downloads/web2py/applications/EveMarket/models/tasks.py" 
>> <http://127.0.0.1:8000/admin/default/edit/EveMarket/models/tasks.py>, line 
>> 101, in 
>> Scheduler(db,dict(update_market=main))
>>   File "/home/johnnyfive/Downloads/web2py/gluon/scheduler.py", line 449, in 
>> __init__
>> self.define_tables(db, migrate=migrate)
>>   File "/home/johnnyfive/Downloads/web2py/gluon/scheduler.py", line 513, in 
>> define_tables
>> migrate=migrate)
>>   File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 7186, in 
>> define_table
>> table = self.lazy_define_table(tablename,*fields,**args)
>>   File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 7203, in 
>> lazy_define_table
>> table = table_class(self, tablename, *fields, **args)
>>   File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 7609, in 
>> __init__
>> db.check_reserved_keyword(field_name)
>>   File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 6930, in 
>> check_reserved_keyword
>> 'invalid table/column name "%s" is a "%s" reserved SQL keyword' % (name, 
>> backend.upper()))
>> SyntaxError: invalid table/column name "output" is a "ALL" reserved SQL 
>> keyword
>>
>>
>> Variablesbackend'all'name'output'backend.upper> str object>
>>
>> Any ideas? I'm feeling like the task scheduler is trying to create a 
>> database column with the name of "output"?
>>
>> Thanks!
>>
>>

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Adding a scheduled task using the scheduler results in db error.

2013-02-01 Thread Morgan Hein
Howdy!

I have been following the video tutorial to create a schedule task. 

Inside the bottom of the task to be run I have:

def main():
o = MarketReader()
o.run()

from gluon.scheduler import Scheduler
Scheduler(db,dict(update_market=main))


When I browse back to the database management, I receive the following 
error:

TICKET ID

127.0.0.1.2013-02-01.19-58-07.6e66c0a0-a0fa-49e0-b6b6-70ddb741fbeb
 invalid table/column name "output" is a 
"ALL" reserved SQL keywordVERSIONweb2py™(2, 3, 2, datetime.datetime(2012, 12
, 17, 15, 3, 30), 'stable')PythonPython 2.7.3: /usr/bin/python

Traceback (most recent call last):
  File "/home/johnnyfive/Downloads/web2py/gluon/restricted.py", line 212, in 
restricted
exec ccode in environment
  File 
"/home/johnnyfive/Downloads/web2py/applications/EveMarket/models/tasks.py" 
, line 101, 
in 
Scheduler(db,dict(update_market=main))
  File "/home/johnnyfive/Downloads/web2py/gluon/scheduler.py", line 449, in 
__init__
self.define_tables(db, migrate=migrate)
  File "/home/johnnyfive/Downloads/web2py/gluon/scheduler.py", line 513, in 
define_tables
migrate=migrate)
  File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 7186, in 
define_table
table = self.lazy_define_table(tablename,*fields,**args)
  File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 7203, in 
lazy_define_table
table = table_class(self, tablename, *fields, **args)
  File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 7609, in __init__
db.check_reserved_keyword(field_name)
  File "/home/johnnyfive/Downloads/web2py/gluon/dal.py", line 6930, in 
check_reserved_keyword
'invalid table/column name "%s" is a "%s" reserved SQL keyword' % (name, 
backend.upper()))
SyntaxError: invalid table/column name "output" is a "ALL" reserved SQL keyword


Variablesbackend'all'name'output'backend.upper

Any ideas? I'm feeling like the task scheduler is trying to create a 
database column with the name of "output"?

Thanks!

-- 

--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.