[Checkins]
SVN: z3c.contents/branches/darrylcousins/src/z3c/contents/
Added SortedColumnHeader adpater registration to the contents
table implementation, only a brief browser test to go with it.
Darryl Cousins
darryl at darrylcousins.net.nz
Thu Mar 13 00:23:20 EDT 2008
Log message for revision 84631:
Added SortedColumnHeader adpater registration to the contents table implementation, only a brief browser test to go with it.
Changed:
U z3c.contents/branches/darrylcousins/src/z3c/contents/BROWSER.txt
U z3c.contents/branches/darrylcousins/src/z3c/contents/column.py
U z3c.contents/branches/darrylcousins/src/z3c/contents/configure.zcml
U z3c.contents/branches/darrylcousins/src/z3c/contents/ftests.py
-=-
Modified: z3c.contents/branches/darrylcousins/src/z3c/contents/BROWSER.txt
===================================================================
--- z3c.contents/branches/darrylcousins/src/z3c/contents/BROWSER.txt 2008-03-13 04:08:50 UTC (rev 84630)
+++ z3c.contents/branches/darrylcousins/src/z3c/contents/BROWSER.txt 2008-03-13 04:23:19 UTC (rev 84631)
@@ -1,6 +1,16 @@
-z3c.contents
-============
+========
+Contents
+========
+The goal of this package is to offer a modular replacement for the default
+contents.html page used in Zope3.
+
+Initially
+=========
+
+In ftesting.zcml we have set up a test layer to use for the following tests and
+have also registered a Contents view as 'index' for the root folder:
+
>>> from z3c.etestbrowser.testing import ExtendedTestBrowser
>>> import zope.component
>>> browser = ExtendedTestBrowser()
@@ -9,4 +19,18 @@
>>> URL = 'http://localhost/++skin++ContentsTesting%s'
>>> browser.open(URL % '/')
- >>> #print browser.contents
+ >>> printElement(browser, "//table/thead/tr/th", multiple=True)
+ <th>X</th>
+ <th><a
+ href="?contents-sortOn=contents-renameColumn-1&contents-sortOrder=ascending"
+ title="Sort">Name</a></th>
+ <th><a
+ href="?contents-sortOn=contents-createdColumn-2&contents-sortOrder=ascending"
+ title="Sort">Created</a></th>
+ <th><a
+ href="?contents-sortOn=contents-modifiedColumn-3&contents-sortOrder=ascending"
+ title="Sort">Modified</a></th>
+
+Sample data set up
+==================
+
Modified: z3c.contents/branches/darrylcousins/src/z3c/contents/column.py
===================================================================
--- z3c.contents/branches/darrylcousins/src/z3c/contents/column.py 2008-03-13 04:08:50 UTC (rev 84630)
+++ z3c.contents/branches/darrylcousins/src/z3c/contents/column.py 2008-03-13 04:23:19 UTC (rev 84631)
@@ -70,3 +70,4 @@
itemLink, key, newName, msg)
else:
return itemLink
+
Modified: z3c.contents/branches/darrylcousins/src/z3c/contents/configure.zcml
===================================================================
--- z3c.contents/branches/darrylcousins/src/z3c/contents/configure.zcml 2008-03-13 04:08:50 UTC (rev 84630)
+++ z3c.contents/branches/darrylcousins/src/z3c/contents/configure.zcml 2008-03-13 04:23:19 UTC (rev 84631)
@@ -38,6 +38,33 @@
provides="z3c.table.interfaces.IColumn"
/>
+ <!-- include also sorting column headers for some columns
+ leaving out CheckBoxColumn -->
+ <adapter
+ factory="z3c.table.column.SortingColumnHeader"
+ for="zope.app.container.interfaces.IContainer
+ zope.interface.Interface
+ z3c.contents.column.RenameColumn"
+ provides="z3c.table.interfaces.IColumnHeader"
+ />
+
+ <adapter
+ factory="z3c.table.column.SortingColumnHeader"
+ for="zope.app.container.interfaces.IContainer
+ zope.interface.Interface
+ z3c.table.column.CreatedColumn"
+ provides="z3c.table.interfaces.IColumnHeader"
+ />
+
+ <adapter
+ factory="z3c.table.column.SortingColumnHeader"
+ for="zope.app.container.interfaces.IContainer
+ zope.interface.Interface
+ z3c.table.column.ModifiedColumn"
+ provides="z3c.table.interfaces.IColumnHeader"
+ />
+
+
<include file="browser.zcml" />
</configure>
Modified: z3c.contents/branches/darrylcousins/src/z3c/contents/ftests.py
===================================================================
--- z3c.contents/branches/darrylcousins/src/z3c/contents/ftests.py 2008-03-13 04:08:50 UTC (rev 84630)
+++ z3c.contents/branches/darrylcousins/src/z3c/contents/ftests.py 2008-03-13 04:23:19 UTC (rev 84631)
@@ -1,5 +1,6 @@
import os
import doctest
+import lxml
import transaction
from zope.app.testing import functional
@@ -10,9 +11,20 @@
TestLayer = functional.ZCMLLayer(
ftesting_zcml, __name__, 'TestLayer')
+def printElement(browser, xpath, multiple=False, serialize=True):
+ """Print method to use with z3c.etestbrowser"""
+ result = [serialize and lxml.etree.tounicode(elem) or elem
+ for elem in browser.etree.xpath(xpath)]
+ if not multiple:
+ print result[0]
+ return
+ for elem in result:
+ print elem
+
def setUp(test):
functional.FunctionalTestSetup().setUp()
test.globs['getRootFolder'] = functional.getRootFolder
+ test.globs['printElement'] = printElement
def tearDown(test):
functional.FunctionalTestSetup().tearDown()
More information about the Checkins
mailing list