I am trying to create a task where every night the following function is 
run to decrement the days left on my sticky entries. When I call the 
function using a controller it does exactly as planned where it grabs the 
sticky entries and decrements the day by 1. When I use the scheduler it 
runs, but it doesn't update the database records. Am I doing something 
wrong?

# coding: utf8
def stickies():
    sticky_entries = db(db.journal.is_sticky == True).select()
    for sticky in sticky_entries:
        days = sticky.days - 1
        if days == 0:
            sticky.is_sticky = False
        sticky.days = days
        sticky.update_record()
    return

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

-- 
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/groups/opt_out.

Reply via email to