[Checkins] SVN: z3c.table/branches/darrylcousins/src/z3c/table/
Added method to header to collect request arguments - use
case is to maintain search term across requests
Darryl Cousins
darryl at darrylcousins.net.nz
Sat Mar 22 21:40:51 EDT 2008
Log message for revision 84860:
Added method to header to collect request arguments - use case is to maintain search term across requests
Changed:
U z3c.table/branches/darrylcousins/src/z3c/table/header.py
U z3c.table/branches/darrylcousins/src/z3c/table/interfaces.py
-=-
Modified: z3c.table/branches/darrylcousins/src/z3c/table/header.py
===================================================================
--- z3c.table/branches/darrylcousins/src/z3c/table/header.py 2008-03-23 01:38:39 UTC (rev 84859)
+++ z3c.table/branches/darrylcousins/src/z3c/table/header.py 2008-03-23 01:40:51 UTC (rev 84860)
@@ -12,7 +12,7 @@
#
##############################################################################
"""
-$Id:$
+$Id$
"""
__docformat__ = "reStructuredText"
@@ -28,6 +28,8 @@
zope.interface.implements(interfaces.IColumnHeader)
+ _request_args = []
+
def __init__(self, context, request, table, column):
self.__parent__ = context
self.context = context
@@ -43,7 +45,22 @@
"""Override this method in subclasses"""
return self.column.header
+ def getQueryStringArgs(self):
+ """
+ Collect additional terms from the request and include in sorting column
+ headers
+ Perhaps this should be in separate interface only for sorting headers?
+
+ """
+ args = {}
+ for key in self._request_args:
+ value = self.request.get(key, None)
+ if value:
+ args.update({key: value})
+ return args
+
+
class SortingColumnHeader(ColumnHeader):
"""Sorting column header."""
@@ -70,8 +87,9 @@
if currentSortOrder == table.sortOrder:
sortOrder = table.reverseSortOrderNames[0]
- args = {'%s-sortOn' % prefix: colID,
- '%s-sortOrder' % prefix: sortOrder}
+ args = self.getQueryStringArgs()
+ args.update({'%s-sortOn' % prefix: colID,
+ '%s-sortOrder' % prefix: sortOrder})
queryString = '?%s' % (urlencode(args))
return '<a href="%s" title="Sort">%s</a>' % (queryString,
Modified: z3c.table/branches/darrylcousins/src/z3c/table/interfaces.py
===================================================================
--- z3c.table/branches/darrylcousins/src/z3c/table/interfaces.py 2008-03-23 01:38:39 UTC (rev 84859)
+++ z3c.table/branches/darrylcousins/src/z3c/table/interfaces.py 2008-03-23 01:40:51 UTC (rev 84860)
@@ -245,3 +245,12 @@
def render():
"""Override this method in subclasses"""
+
+ def getQueryStringArgs():
+ """
+ Because the header will most often be used to add links for sorting the
+ columns it may also be necessary to collect other query arguments from
+ the request.
+
+ The initial use case here is to maintain a search term.
+ """
More information about the Checkins
mailing list