work in progress: grid (records) field

git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3004 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2008-11-21 17:47:47 +00:00
parent 13d5d43021
commit 3ac67abd37
2 changed files with 13 additions and 2 deletions

View file

@ -39,6 +39,8 @@ class Email(schema.TextLine):
# put field type name and other info in standard field classes. # put field type name and other info in standard field classes.
schema.Field.__typeInfo__ = ('textline',) schema.Field.__typeInfo__ = ('textline',)
schema.Int.__typeInfo__ = ('number',)
schema.Float.__typeInfo__ = ('number',)
schema.Choice.__typeInfo__ = ('dropdown',) schema.Choice.__typeInfo__ = ('dropdown',)

View file

@ -78,13 +78,22 @@ class GridFieldInstance(ListFieldInstance):
return dict(headers=headers, rows=rows) return dict(headers=headers, rows=rows)
def unmarshall(self, value): def unmarshall(self, value):
value = value.strip()
if not value: if not value:
return [] return []
result = [] result = []
rows = json.loads(value)['items'] rows = json.loads(value)['items']
for row in rows: for row in rows:
item = {} item = {}
empty = True
for fi in self.columnFieldInstances: for fi in self.columnFieldInstances:
item[fi.name] = fi.unmarshall(row[fi.name]) value = fi.unmarshall(row[fi.name])
item[fi.name] = value
if fi.default is not None:
if value != fi.default:
empty = False
elif value:
empty = False
if not empty:
result.append(item) result.append(item)
return result return result