On 1/3/07, dundeemt <[EMAIL PROTECTED]> wrote:

In the scheduler module in the Trunk, there are these two classes based
in part on Task:

class Task:
    """Abstract base class of all scheduler tasks"""
    [...]
    def execute(self):
        """Execute the actual task."""
        self.action(*self.args, **self.kw)

class WeekdayTask(DayTaskRescheduler, Task):
    """A task that is called at specific days in a week (1-7), at a
fixed time on the day."""
    [...]
    def execute(self):
        # This is called every day, at the correct time. We only need
to
        # check if we should run this task today (this day of the
week).
        weekday=time.localtime().tm_wday+1
        if weekday in self.days:
            self.action(*self.args, **self.kw)

class MonthdayTask(DayTaskRescheduler, Task):
    """A task that is called at specific days in a month (1-31), at a
fixed time on the day."""
    [...]
    def execute(self):
        # This is called every day, at the correct time. We only need
to
        # check if we should run this task today (this day of the
month).
        if time.localtime().tm_mday in self.days:
            self.action(*self.args, **self.kw)

The execute method is over riding the base Task.execute() method, since
there are only trivial conditionals being checked and no changes what
so ever to the base method (execute) why is self.action(*self.args,
**self.kw) being called in them, instead of Task.execute() which should
send it back to the base class, where it would execute the action?

it's been a while since I look at that code but I don't see why it is
different maybe the original author (remember that module was a
standalone project that got integrated into TG) wanted to make it more
clear and since it was a one liner it could spare the extra call in
the stack.

I came across this code repetition while working on scheduler in my own
project -- and since it's such a clever piece of code, I'm not
confident that there isn't a good reason why this is done -- so I'm
asking for feedback.

as I said one hop less in the stack


Thanks,

Jeff


>


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