diff --git a/browser/action.py b/browser/action.py index c3618f6..128ce39 100644 --- a/browser/action.py +++ b/browser/action.py @@ -86,6 +86,11 @@ class ActionRegistry(object): catItem = self.actionsByCategory.setdefault(category, []) catItem.append(action) + def getAction(self, name, category): + for a in self.actionsByName[name]: + if a.category == category: + return a + def get(self, category=None, names=[], view=None, **kw): if view is None: raise ValueError("The 'view' argument is missing.") diff --git a/composer/schema/grid/field.py b/composer/schema/grid/field.py index 81d6c61..d559cac 100644 --- a/composer/schema/grid/field.py +++ b/composer/schema/grid/field.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2008 Helmut Merz helmutm@cy55.de +# Copyright (c) 2009 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -61,7 +61,6 @@ class GridFieldInstance(ListFieldInstance): return value v = value or [] for row in v: - #for k, vr in row.items(): for fi in self.columnFieldInstances: vr = fi.marshall(row[fi.name]) if isinstance(vr, basestring): @@ -106,3 +105,34 @@ class GridFieldInstance(ListFieldInstance): if not empty: result.append(item) return result + + +class RecordsFieldInstance(GridFieldInstance): + + def marshall(self, value): + result = [] + for row in value or []: + item = {} + for fi in self.columnFieldInstances: + item[fi.name] = fi.marshall(row[fi.name]) + result.append(item) + return result + + def unmarshall(self, value): + if not value: + value = [] + result = [] + for row in value: + item = {} + empty = True + for fi in self.columnFieldInstances: + value = fi.unmarshall(row[fi.name].strip()) + item[fi.name] = value + if fi.default is not None: + if value and value != fi.default: + empty = False + elif value: + empty = False + if not empty: + result.append(item) + return result diff --git a/composer/schema/grid/grid_macros.pt b/composer/schema/grid/grid_macros.pt index 09d3ac7..26031cb 100755 --- a/composer/schema/grid/grid_macros.pt +++ b/composer/schema/grid/grid_macros.pt @@ -38,5 +38,33 @@ + + + + + + + + + + + + + +
Column Title
+
+

+
+ + diff --git a/composer/schema/grid/interfaces.py b/composer/schema/grid/interfaces.py index 52b5e92..b9cb4af 100644 --- a/composer/schema/grid/interfaces.py +++ b/composer/schema/grid/interfaces.py @@ -40,3 +40,12 @@ class Grid(schema.List): instanceName='grid')) column_types = [] + + +class Records(Grid): + + __typeInfo__ = ('records', + FieldType('records', 'records', + u'A series of records or rows.', + instanceName='records',)) +