you're doing "all" wrong. Stop copy/pasting for a sec and take a look to 
docs.....it'll save you from multiple headaches.

in this case, you're "doing wrong" form processing.

It's either

form = SQLFORM(...)
if form.accepts(request.vars, session):
    ....things to do when form is valid
elif form.errors:
    ....things to do when form has errors
else:
    ....things to do when page is loaded the first time
return dict(form=form)



or (newer)

form = SQLFORM(...)
if form.process().accepted:
    ....things to do when form is valid
elif form.errors:
    ....things to do when form has errors
else:
    ....things to do when page is loaded the first time
return dict(form=form)




On Tuesday, April 22, 2014 7:32:03 PM UTC+2, ureal frank wrote:
>
> Hi,
>
> /newbie here/
>
> I’ve up and running a very very simple task scheduler but I think it’s not 
> well designed :/
>
> under models/scheduler.py I have:
>
> "
> from gluon.scheduler import Scheduler
>
> def task_add(name, target):
>     sum = 'hello ' + name + ' ' + target + '\n'
>     with open('/tmp/tasks', 'w') as f:
>         f.write(sum)
>
> scheduler = Scheduler(db, dict(task_add=task_add))
> “
>
> and in controller:
>
> “
> def new():
>
>     form = SQLFORM(db.scan)
>  
>     name = “”
>     target = “"
>
>     if form.process().accepts(request.vars, session):
>
>         name = form.vars.name
>         target = form.vars.target
>
>         response.flash = ‘Great scan'
>
>     elif form.errors:
>         response.flash = 'Error, try again'
>
>     scheduler.queue_task('task_add’,
> pargs=[],
>         pvars={'name': name, 'target': target},
>         start_time=request.now,     #datetime
>         stop_time = None,           #datetime
>         timeout = 60,               #seconds
>         prevent_drift=False,
>         period=60,                  #seconds
>         immediate=False,
>         repeats = 1)
>
>     return dict(scans=scans, form=form)
> “
>
> This snippet is working but I think this “scheduler.queue_task(…)” should 
> be processed inside “if form.process().accepts()”. But if I change the 
> scheduler snipper into that code section, the task wont run and I don’t 
> know why.
>
> two: questions
> 1) what I am  doing wrong?
> 1.1) Maybe I should db.commit when the task is over. Should I code this 
> under scheduler.py? 
> 2) where can I learn more about debugging?
>
> Many many thanks in advance :)
>
> Cheers,
> -- 
> Frank
>

-- 
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.

Reply via email to