From 3ac67abd3709d1ad444ecd70b18b9b1028625c42 Mon Sep 17 00:00:00 2001 From: helmutm Date: Fri, 21 Nov 2008 17:47:47 +0000 Subject: [PATCH] work in progress: grid (records) field git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3004 fd906abe-77d9-0310-91a1-e0d9ade77398 --- composer/schema/factory.py | 2 ++ composer/schema/grid/field.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/composer/schema/factory.py b/composer/schema/factory.py index 183def5..ff97900 100644 --- a/composer/schema/factory.py +++ b/composer/schema/factory.py @@ -39,6 +39,8 @@ class Email(schema.TextLine): # put field type name and other info in standard field classes. schema.Field.__typeInfo__ = ('textline',) +schema.Int.__typeInfo__ = ('number',) +schema.Float.__typeInfo__ = ('number',) schema.Choice.__typeInfo__ = ('dropdown',) diff --git a/composer/schema/grid/field.py b/composer/schema/grid/field.py index aca06b6..7be071f 100644 --- a/composer/schema/grid/field.py +++ b/composer/schema/grid/field.py @@ -78,13 +78,22 @@ class GridFieldInstance(ListFieldInstance): return dict(headers=headers, rows=rows) def unmarshall(self, value): + value = value.strip() if not value: return [] result = [] rows = json.loads(value)['items'] for row in rows: item = {} + empty = True for fi in self.columnFieldInstances: - item[fi.name] = fi.unmarshall(row[fi.name]) - result.append(item) + 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) return result