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 import component
|
||||||
from zope.i18n.format import DateTimeParseError
|
from zope.i18n.format import DateTimeParseError
|
||||||
from zope.i18n.locales import locales
|
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.engine import Engine
|
||||||
from zope.tales.tales import Context
|
from zope.tales.tales import Context
|
||||||
|
|
||||||
|
@ -137,8 +137,15 @@ class Field(Component):
|
||||||
return terms
|
return terms
|
||||||
voc = voc.splitlines()
|
voc = voc.splitlines()
|
||||||
return [dict(token=t, title=t) for t in voc if t.strip()]
|
return [dict(token=t, title=t) for t in voc if t.strip()]
|
||||||
else:
|
elif IContextSourceBinder.providedBy(voc):
|
||||||
return [dict(token=t.token, title=t.title or t.value) for t in 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):
|
def getVocabularyTerms(self, name, context, request):
|
||||||
if context is None or request is None:
|
if context is None or request is None:
|
||||||
|
|
|
@ -162,6 +162,8 @@ class KeyTableFieldInstance(RecordsFieldInstance):
|
||||||
def display(self, value):
|
def display(self, value):
|
||||||
headers = [fi.context.title for fi in self.columnFieldInstances]
|
headers = [fi.context.title for fi in self.columnFieldInstances]
|
||||||
rows = []
|
rows = []
|
||||||
|
if value is None:
|
||||||
|
value = {}
|
||||||
for k, v in value.items():
|
for k, v in value.items():
|
||||||
row = [k]
|
row = [k]
|
||||||
for idx, fi in enumerate(self.columnFieldInstances[1:]):
|
for idx, fi in enumerate(self.columnFieldInstances[1:]):
|
||||||
|
|
Loading…
Add table
Reference in a new issue