[Checkins] SVN: z3c.table/trunk/ Allow to initialze the column definitions without requiring an entire table update
Laurent Mignon
Laurent.Mignon at softwareag.com
Tue May 26 15:03:36 EDT 2009
Log message for revision 100433:
Allow to initialze the column definitions without requiring an entire table update
Changed:
U z3c.table/trunk/CHANGES.txt
U z3c.table/trunk/src/z3c/table/README.txt
U z3c.table/trunk/src/z3c/table/interfaces.py
U z3c.table/trunk/src/z3c/table/table.py
-=-
Modified: z3c.table/trunk/CHANGES.txt
===================================================================
--- z3c.table/trunk/CHANGES.txt 2009-05-26 18:03:24 UTC (rev 100432)
+++ z3c.table/trunk/CHANGES.txt 2009-05-26 19:03:36 UTC (rev 100433)
@@ -5,7 +5,7 @@
Version 0.6.2dev (unreleased)
-----------------------------
-- ...
+- Allow to initialze the column definitions without requiring an entire table update.
Version 0.6.1 (2009-02-22)
Modified: z3c.table/trunk/src/z3c/table/README.txt
===================================================================
--- z3c.table/trunk/src/z3c/table/README.txt 2009-05-26 18:03:24 UTC (rev 100432)
+++ z3c.table/trunk/src/z3c/table/README.txt 2009-05-26 19:03:36 UTC (rev 100433)
@@ -1742,6 +1742,31 @@
>>> simpleTable.render()
u''
+Since we have registered 3 adapters for IColumn on None (IOW on an empty mapping),
+initializing rows definitions for the empty table will initiliaze the columns attribute list
+
+ >>> simpleTable.columns
+
+ >>> simpleTable.initColumns()
+ >>> simpleTable.columns
+ [<CorrectColspanColumn u'colspanColumn'>, <NameColumn u'secondColumn'>, <TitleColumn u'firstColumn'>]
+
+Rendering the empty table now return the string:
+
+ >>> print simpleTable.render()
+ <table>
+ <thead>
+ <tr>
+ <th>Colspan</th>
+ <th><a href="?table-sortOrder=ascending&table-sortOn=table-secondColumn-1" title="Sort">Name</a></th>
+ <th><a href="?table-sortOrder=ascending&table-sortOn=table-firstColumn-2" title="Sort">Title</a></th>
+ </tr>
+ </thead>
+ <tbody>
+ </tbody>
+ </table>
+
+
Let's see if the addColumn raises a ValueError if there is no Column class:
>>> column.addColumn(simpleTable, column.Column, u'dummy')
Modified: z3c.table/trunk/src/z3c/table/interfaces.py
===================================================================
--- z3c.table/trunk/src/z3c/table/interfaces.py 2009-05-26 18:03:24 UTC (rev 100432)
+++ z3c.table/trunk/src/z3c/table/interfaces.py 2009-05-26 19:03:36 UTC (rev 100433)
@@ -98,7 +98,7 @@
description=_(u'Reverse sort order name')
),
default=[u'descending', u'reverse', u'down'],
- required=False)
+ required=False)
# batch attributes
batchStart = zope.schema.Int(
@@ -127,6 +127,9 @@
def updateColumns():
"""Update columns."""
+ def initColumns():
+ """Initialize columns definitions used by the table"""
+
def orderColumns():
"""Order columns."""
@@ -187,9 +190,9 @@
class ISequenceTable(ITable):
"""Sequence table adapts a sequence as context.
-
+
This table can be used for adapting a z3c.indexer.search.ResultSet or
- z3c.batching.batch.Batch instance as context. Batch which wraps a
+ z3c.batching.batch.Batch instance as context. Batch which wraps a
ResultSet sequence.
"""
Modified: z3c.table/trunk/src/z3c/table/table.py
===================================================================
--- z3c.table/trunk/src/z3c/table/table.py 2009-05-26 18:03:24 UTC (rev 100432)
+++ z3c.table/trunk/src/z3c/table/table.py 2009-05-26 19:03:36 UTC (rev 100433)
@@ -55,15 +55,6 @@
zope.interface.implements(interfaces.ITable)
- # private variables will be set in update call
- batchProvider = None
- columnCounter = 0
- columnIndexById = {}
- columnByName = {}
- columns = None
- rows = None
- selectedItems = []
-
# customize this part if needed
prefix = 'table'
@@ -89,7 +80,22 @@
self.context = context
self.request = request
self.__parent__ = context
+ # private variables will be set in update call
+ self.batchProvider = None
+ self.columnCounter = 0
+ self.columnIndexById = {}
+ self.columnByName = {}
+ self.columns = None
+ self.rows = []
+ self.selectedItems = []
+
+ def initColumns(self):
+ # setup columns
+ self.columns = self.setUpColumns()
+ # order columns
+ self.orderColumns()
+
def getCSSClass(self, element, cssClass=None):
klass = self.cssClasses.get(element)
if klass and cssClass:
@@ -117,6 +123,7 @@
col.update()
def orderColumns(self):
+ self.columnCounter = 0
self.columns = sorted(self.columns, key=getWeight)
for col in self.columns:
self.columnByName[col.__name__] = col
@@ -280,16 +287,13 @@
# use batch values from request or the existing ones
self.batchSize = self.getBatchSize()
self.batchStart = self.getBatchStart()
- # use sorting values from request or the existing ones
+ # use srting values from request or the existing ones
self.sortOn = self.getSortOn()
self.sortOrder = self.getSortOrder()
- # setup columns
- self.columns = self.setUpColumns()
+ # initialize columns
+ self.initColumns()
- # order columns
- self.orderColumns()
-
# update columns
self.updateColumns()
More information about the Checkins
mailing list