use keytable field for datatable data

This commit is contained in:
Helmut Merz 2011-12-23 14:21:50 +01:00
parent 9397df0afa
commit bd2cb55f16
3 changed files with 33 additions and 17 deletions

View file

@ -159,6 +159,10 @@ table.listing th span.descending {
background-repeat: no-repeat;
}
table.records {
border-collapse: collapse;
}
table.records input, table.records textarea {
border: none;
padding: 0;
@ -167,13 +171,13 @@ table.records input, table.records textarea {
}
table.records th {
background-color: lightgrey;
background-color: #fefefe;
}
table.records th, table.records td {
padding: 0;
margin: 0;
border: 1px solid black;
border: 1px solid lightgrey;
}
table.report td {

View file

@ -1,5 +1,3 @@
<!-- $Id$ -->
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:i18n="http://namespaces.zope.org/i18n"
@ -355,6 +353,8 @@
name="grid" />
<adapter factory="cybertools.composer.schema.grid.field.RecordsFieldInstance"
name="records" />
<adapter factory="cybertools.composer.schema.grid.field.ContextBasedKeyTableFieldInstance"
name="keytable" />
<adapter factory="loops.schema.field.RelationSetFieldInstance"
name="relationset" />
<adapter factory="loops.schema.field.RelationFieldInstance"
@ -366,14 +366,10 @@
for="loops.interfaces.IResource" />
<adapter factory="loops.schema.factory.FileSchemaFactory" />
<adapter factory="loops.schema.factory.NoteSchemaFactory" />
<adapter factory="loops.table.DataTableSchemaFactory" />
<adapter factory="loops.setup.SetupManager" />
<!-- obsolete:
<adapter factory="loops.external.NodesLoader" />
<adapter factory="loops.external.NodesExporter" />
<adapter factory="loops.external.NodesImporter" />-->
<!-- obsolete - remove: -->
<adapter factory="loops.target.DocumentProxy"
permission="zope.ManageContent" />
@ -432,10 +428,12 @@
<!-- utilities -->
<utility
provides="cybertools.storage.interfaces.IExternalStorage"
factory="cybertools.storage.filesystem.instanceVarSubdirectoryStorage"
name="varsubdir" />
<utility
provides="cybertools.storage.interfaces.IExternalStorage"
factory="cybertools.storage.filesystem.fullPathStorage"
name="fullpath" />

View file

@ -18,16 +18,16 @@
"""
Data (keyword-based) table definition and implementation.
$Id$
"""
from BTrees.OOBTree import OOBTree
from zope import schema, component
from zope.interface import Interface, Attribute, implements
from zope import component, schema
from zope.component import adapts
from zope.interface import implements, Interface, Attribute
from zope.cachedescriptors.property import Lazy
from cybertools.composer.schema.grid.interfaces import Records
from cybertools.composer.schema.factory import SchemaFactory
from cybertools.composer.schema.grid.interfaces import KeyTable
from loops.common import AdapterBase
from loops.interfaces import IConcept, IConceptSchema, ILoopsAdapter
from loops.type import TypeInterfaceSourceList
@ -47,8 +47,6 @@ class IDataTable(IConceptSchema, ILoopsAdapter):
default=u'',
required=False)
# better: specify column names (and possibly labels, types)
# in Python code and reference by name here
columns = schema.List(
title=_(u'Columns'),
description=_(u'The names of the columns of the data table. '
@ -57,10 +55,12 @@ class IDataTable(IConceptSchema, ILoopsAdapter):
default=['key', 'value'],
required=True)
data = Records(title=_(u'Table Data'),
data = KeyTable(title=_(u'Table Data'),
description=_(u'Table Data'),
required=False)
IDataTable['columns'].hidden = True
class DataTable(AdapterBase):
@ -75,6 +75,8 @@ class DataTable(AdapterBase):
self.context._columns = value
columns = property(getColumns, setColumns)
columnNames = columns
def getData(self):
data = getattr(self.context, '_data', None)
if data is None:
@ -87,3 +89,15 @@ class DataTable(AdapterBase):
TypeInterfaceSourceList.typeInterfaces += (IDataTable,)
class DataTableSchemaFactory(SchemaFactory):
adapts(IDataTable)
def __call__(self, interface, **kw):
schema = super(DataTableSchemaFactory, self).__call__(interface, **kw)
schema.fields.remove('columns')
schema.fields.remove('viewName')
return schema