Can't access scheduler_task table ['DAL' object has no attribute 'scheduler_task']

90 views
Skip to first unread message

Marty Jones

unread,
Apr 29, 2016, 12:05:34 PM4/29/16
to web2py-users
I'm defining some functions in the modules folder that need to access and insert rows into the db. in the controller, I define "current.db = db" then in the module I import the db as seen below.

I define the function below and attempt to import it and queue it up using Scheduler, but receive "'DAL' object has no attribute 'scheduler_task'". What am I missing?

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from gluon import *
from gluon import current

def insert_task():
    db = current.db
    db.scheduler_task.insert(status = 'QUEUED',
                             application_name = 'my_application/default',
                             task_name = 'download',
                             group_name = 'scrape',
                             function_name = 'download',
                             args = '[]',
                             vars = '{}',
                             enabled = True,
                             start_time = request.now,
                             timeout = 500,
                             )


Dave S

unread,
Apr 29, 2016, 2:44:30 PM4/29/16
to web2py-users
Have you instantiated the scheduler elsewhere?  I don't think the tables exist until the first time you do, and it's not worth the effort to create your own table def and try to get all the fields to match.

/dps
 

Marty Jones

unread,
Apr 29, 2016, 3:17:37 PM4/29/16
to web2py-users
I seem to have resolved it by switching "db = current.db" to "db = current.globalenv['db']"

Niphlod

unread,
May 1, 2016, 12:00:44 PM5/1/16
to web2py-users
why don't you use queue_task() ?

Marty Jones

unread,
May 1, 2016, 10:54:00 PM5/1/16
to web2py-users
how would I import the scheduler into a module to do that?

Niphlod

unread,
May 2, 2016, 3:51:08 AM5/2/16
to web2py-users
how did you "import" the database ? referencing a "current"... same applies to the scheduler
Reply all
Reply to author
Forward
0 new messages