I'm working on teasing the scheduling parts of TracJSGantt out into a second 
class or maybe a second plugin so that the scheduling algorithm is pluggable.  
I have it as an ExtensionPoint that implements ITaskScheduler but I'm not sure 
this is quite the right thing to do.

In most cases, there will or should be only one scheduler in an installation so 
I want the scheduler to be a singleton.  Following the examples at 
http://trac.edgewall.org/wiki/TracDev/ComponentArchitecture, I tried something 
like:

  schedulers = ExtensionPoint(ITaskSchedler)

  if len(schedulers) == 0:
     ..error, need at least one..
  elif len(schedluers) > 1:
     ..error, how do I choose? ..
  else
     schedulers[0].scheduleTasks(...)

But ExtentionPoint seems to return an iterator.  I guess I could do:

  i = 0
  for s in schedulers: 
     i = i+1
  if i == 0:
     ...

But that seems awkward.

A component is a singleton but if I made the scheduler a component, I don't 
know how to *find* it in my code.

Alternatively, if I have more than one, I'd like to be able to index them by 
name so that application code could say  "schedule('simple', ...)" or 
"schedule('resourceLevel', ...)".  I guess I could do that with:

  found = False
  for s in schedulers:
     if s.name() == userScheduleName
        s.scheduleTasks(...)
        found = True
  if not Found:
     ...error, unknown name...

But I'm unsure if there is a better idiom.

Thanks in advance for any guidance you can provide.  My Python is weak and my 
knowledge of Trac internals is weaker.

                                                        Chris
-- 
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 
Development" 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-dev?hl=en.

Reply via email to