from Acquisition import aq_inner, aq_parent
from zope.schema.interfaces import IContextSourceBinder
from zope.schema.vocabulary import SimpleVocabulary
...
@grok.provider(IContextSourceBinder)
def possibleTracks(context):
# we put the import here to avoid a circular import
from example.conference.program import IProgram
while context is not None and not IProgram.providedBy(context):
context = aq_parent(aq_inner(context))
values = []
if context is not None and context.tracks:
values = context.tracks
return SimpleVocabulary.fromValues(values)