I have a couple of Trac components, one is derived from the other
(below). When I try to use the components, I get an error:
Unable to instantiate component <class
'tracjsgantt.tracpm.CalendarScheduler'> (maybe_init() takes
at least 2 arguments (1 given))
Replacing "super(CalendarScheduler, self).__init__()" with
"SimpleScheduler.__init__(self)" gives the same error.
Is there something about Component that makes super() misbehave. I'm
kind of new to Python objects so I'm likely doing something stupid. Any
pointers appreciated. Thanks.
-----------------8<---------------------->8--------------------
class ITaskScheduler(Interface):
def scheduleTasks(self, options, tickets):
"""Called to schedule tasks"""
class IResourceCalendar(Interface):
def hoursAvailable(self, date, resource = None):
"""Called to see how many hours are available on date"""
class SimpleScheduler(Component):
implements(ITaskScheduler)
def __init__(self):
# Instantiate the PM component
self.pm = TracPM(self.env)
# ITaskScheduler method
# Uses options hoursPerDay and schedule (alap or asap).
def scheduleTasks(self, options, tickets):
# Faster lookups
self.ticketsByID = {}
for t in tickets:
self.ticketsByID[t['id']] = t
# <snip>
for id in self.ticketsByID:
if options['schedule'] == 'alap':
_schedule_task_alap(self.ticketsByID[id])
else:
_schedule_task_asap(self.ticketsByID[id])
class SimpleCalendar(Component):
implements(IResourceCalendar)
def __init__(self):
self.env.log.debug('Creating a simple calendar')
"""Nothing"""
def hoursAvailable(self, date, resource=None):
return 8.0
class CalendarScheduler(SimpleScheduler):
# FIXME is this needed or is it inherited from SimpleScheduler?
implements(ITaskScheduler)
cal = ExtensionOption('TracPM', 'calendar',
IResourceCalendar, 'SimpleCalendar')
def __init__(self):
super(CalendarScheduler, self).__init__()
# Instantiate the PM component
# self.pm = TracPM(self.env)
# self.cal = SimpleCalendar(self.env)
self.env.log.info('CalendarScheduler active')
# <snip>
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com
--
You received this message because you are subscribed to the Google Groups "Trac
Users" 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/trac-users?hl=en.