Hi,
I've web2py 2.3 version. I tried to use scheduler for mail sending.
I got this error while creating a worker for scheduler
$ python web2py.py -K send_mail_app
[12:07:02]
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2014
Version 2.3.2 (2012-12-17 15:03:30) stable
Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000),
MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), IMAP(imaplib)
starting single-scheduler for "send_mail_app"...
Traceback (most recent call last):
File "/home/prasad/Rootpy/web2py 2.3/gluon/restricted.py", line 212, in
restricted
exec ccode in environment
File "applications/send_mail_app/models/scheduler.py", line 2, in <module>
mail_scheduler = Scheduler(db)
File "/home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py", line 449, in
__init__
self.define_tables(db, migrate=migrate)
File "/home/prasad/Rootpy/web2py 2.3/gluon/scheduler.py", line 501, in
define_tables
migrate=migrate, format='%(task_name)s')
File "/home/prasad/Rootpy/web2py 2.3/gluon/dal.py", line 7186, in
define_table
table = self.lazy_define_table(tablename,*fields,**args)
File "/home/prasad/Rootpy/web2py 2.3/gluon/dal.py", line 7222, in
lazy_define_table
polymodel=polymodel)
File "/home/prasad/Rootpy/web2py 2.3/gluon/dal.py", line 935, in
create_table
self.create_sequence_and_triggers(query,table)
File "/home/prasad/Rootpy/web2py 2.3/gluon/dal.py", line 1694, in
create_sequence_and_triggers
self.execute(query)
File "/home/prasad/Rootpy/web2py 2.3/gluon/dal.py", line 1709, in execute
return self.log_execute(*a, **b)
File "/home/prasad/Rootpy/web2py 2.3/gluon/dal.py", line 1703, in
log_execute
ret = self.cursor.execute(*a, **b)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line
201, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py",
line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1050, "Table 'scheduler_task' already exists")
I've followed following instructions.
*1) Created a file models/scheduler.py*
#code from scheduler.py file
from gluon.scheduler import Scheduler
mail_scheduler = Scheduler(db)
def send_mail(to, subject, message, cc=None, bcc=None,
attachments=None):
"""
This module is called by scheduler.
You can check scheduler_task table and scheduler.task_status table
"""
if cc is None:
cc = []
if bcc is None:
bcc = []
if attachments is None:
attachments = []
#sending mail
mail.send(to=to, cc=cc, bcc=bcc,
subject=subject, message=message,
attachments=attachments)
*2) Called send_mail module in an external script.*
(scripts/send_mails.py)
#extra code here
task = mail_scheduler.queue_task('send_mail',
pvars={'to': email,
'subject': subject,
'message': html_email},
start_time=datetime.datetime.now())
print task
*3) Created a worker and got above error*
Am I missing some steps?
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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/d/optout.