I'm trying to use TurboGears' scheduler to automate sending bills by 
email.  I have this code as a controller method:

    def send1MonthBills(self):
        '''Email bills for projects marked billable where frequency is 1 
Month'''
        projects = model.Project.select(model.Project.q.billable==True)
        for p in projects:
            if p.billFrequency.frequency=='1 Month':
                self.emailBill(p.id)
                print "emailed bill for %s" % p.name
    scheduler.add_monthday_task(action=send1MonthBills, 
taskname='send1MonthBills', monthdays=[1], timeonday=(9,0))
##    scheduler.add_interval_task(action=send1MonthBills, 
taskname='send1MonthBillsTest', initialdelay=10, interval=60)

Since it's a controller method, send1MonthBills() requires 1 argument:  
self, and it references the controller class (Root()) when it calls 
self.emailBill(), which is @exposed in order to use a template to make 
the email pretty.

The problem is, scheduler.add_monthday_task(action=send1MonthBills... 
doesn't let me enter "self" as an argument to send1MonthBills, so I get 
this error:

ERROR DURING TASK EXECUTION send1MonthBills() takes exactly 1 argument 
(0 given)
...
TypeError: send1MonthBills() takes exactly 1 argument (0 given)

So, is there a way to either:

- give send1MonthBills() the "self" argument? I don't think there is.
- or to call self.emailBill() from outside the controller class, but 
within controllers.py?  I think this is what I need to do, but can't 
find documentation on it.  I tried importing cherrypy then calling 
cherrypy.root.emailBill() and it didn't work.

Tim Black


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to