merge branch 'master'
This commit is contained in:
commit
694cef4585
2 changed files with 12 additions and 3 deletions
|
@ -30,7 +30,7 @@ from zope.component import adapts
|
|||
from zope import component
|
||||
from zope.i18n.format import DateTimeParseError
|
||||
from zope.i18n.locales import locales
|
||||
from zope.schema.interfaces import IVocabularyFactory
|
||||
from zope.schema.interfaces import IVocabularyFactory, IContextSourceBinder
|
||||
from zope.tales.engine import Engine
|
||||
from zope.tales.tales import Context
|
||||
|
||||
|
@ -137,7 +137,14 @@ class Field(Component):
|
|||
return terms
|
||||
voc = voc.splitlines()
|
||||
return [dict(token=t, title=t) for t in voc if t.strip()]
|
||||
elif IContextSourceBinder.providedBy(voc):
|
||||
source = voc(context)
|
||||
terms = component.queryMultiAdapter((source, request), ITerms)
|
||||
if terms is not None:
|
||||
termsList = [terms.getTerm(value) for value in source]
|
||||
return [dict(token=t.token, title=t.title) for t in termsList]
|
||||
else:
|
||||
return None
|
||||
return [dict(token=t.token, title=t.title or t.value) for t in voc]
|
||||
|
||||
def getVocabularyTerms(self, name, context, request):
|
||||
|
|
|
@ -162,6 +162,8 @@ class KeyTableFieldInstance(RecordsFieldInstance):
|
|||
def display(self, value):
|
||||
headers = [fi.context.title for fi in self.columnFieldInstances]
|
||||
rows = []
|
||||
if value is None:
|
||||
value = {}
|
||||
for k, v in value.items():
|
||||
row = [k]
|
||||
for idx, fi in enumerate(self.columnFieldInstances[1:]):
|
||||
|
|
Loading…
Add table
Reference in a new issue