22Customising Roundup
33===================
44
5- :Version: $Revision: 1.29 $
5+ :Version: $Revision: 1.30 $
66
77.. This document borrows from the ZopeBook section on ZPT. The original is at:
88 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
@@ -948,17 +948,23 @@ Method Description
948948=========== =============================================================
949949plain render a "plain" representation of the property
950950field render a form edit field for the property
951- stext specific to String properties - render the value of the
951+ stext only on String properties - render the value of the
952952 property as StructuredText (requires the StructureText module
953953 to be installed separately)
954- multiline specific to String properties - render a multiline form edit
954+ multiline only on String properties - render a multiline form edit
955955 field for the property
956- email specific to String properties - render the value of the
956+ email only on String properties - render the value of the
957957 property as an obscured email address
958+ reldate only on Date properties - render the interval between the
959+ date and now
960+ pretty only on Interval properties - render the interval in a
961+ pretty format (eg. "yesterday")
962+ menu only on Link and Multilink properties - render a form select
963+ list for this property
964+ reverse only on Multilink properties - produce a list of the linked
965+ items in reverse order
958966=========== =============================================================
959967
960- XXX do the other properties
961-
962968The request variable
963969~~~~~~~~~~~~~~~~~~~~
964970
@@ -996,6 +1002,22 @@ filterspec values to filter the index on
9961002search_text text to perform a full-text search on for an index
9971003=========== ================================================================
9981004
1005+ There are several methods available on the request variable:
1006+
1007+ =============== ============================================================
1008+ Method Description
1009+ =============== ============================================================
1010+ description render a description of the request - handle for the page
1011+ title
1012+ indexargs_form render the current index args as form elements
1013+ indexargs_url render the current index args as a URL
1014+ base_javascript render some javascript that is used by other components of
1015+ the templating
1016+ batch run the current index args through a filter and return a
1017+ list of items (see `hyperdb item wrapper`_, and
1018+ `batching`_)
1019+ =============== ============================================================
1020+
9991021The db variable
10001022~~~~~~~~~~~~~~~
10011023
@@ -1010,6 +1032,83 @@ want access to the "user" class, for example, you would use::
10101032The access results in a `hyperdb class wrapper`_.
10111033
10121034
1035+ The util variable
1036+ ~~~~~~~~~~~~~~~~~
1037+
1038+ Note: this is implemented by the roundup.cgi.templating.TemplatingUtils class.
1039+
1040+ =============== ============================================================
1041+ Method Description
1042+ =============== ============================================================
1043+ Batch return a batch object using the supplied list
1044+ =============== ============================================================
1045+
1046+ Batching
1047+ ::::::::
1048+
1049+ Use Batch to turn a list of items, or item ids of a given class, into a series
1050+ of batches. Its usage is::
1051+
1052+ python:util.Batch(sequence, size, start, end=0, orphan=0, overlap=0)
1053+
1054+ or, to get the current index batch::
1055+
1056+ request/batch
1057+
1058+ The parameters are:
1059+
1060+ ========= ==================================================================
1061+ Parameter Usage
1062+ ========= ==================================================================
1063+ sequence a list of HTMLItems
1064+ size how big to make the sequence.
1065+ start where to start (0-indexed) in the sequence.
1066+ end where to end (0-indexed) in the sequence.
1067+ orphan if the next batch would contain less items than this
1068+ value, then it is combined with this batch
1069+ overlap the number of items shared between adjacent batches
1070+ ========= ==================================================================
1071+
1072+ All of the parameters are assigned as attributes on the batch object. In
1073+ addition, it has several more attributes:
1074+
1075+ =============== ============================================================
1076+ Attribute Description
1077+ =============== ============================================================
1078+ start indicates the start index of the batch. *Note: unlike the
1079+ argument, is a 1-based index (I know, lame)*
1080+ first indicates the start index of the batch *as a 0-based
1081+ index*
1082+ length the actual number of elements in the batch
1083+ sequence_length the length of the original, unbatched, sequence.
1084+ =============== ============================================================
1085+
1086+ And several methods:
1087+
1088+ =============== ============================================================
1089+ Method Description
1090+ =============== ============================================================
1091+ previous returns a new Batch with the previous batch settings
1092+ next returns a new Batch with the next batch settings
1093+ propchanged detect if the named property changed on the current item
1094+ when compared to the last item
1095+ =============== ============================================================
1096+
1097+ An example of batching::
1098+
1099+ <table class="otherinfo">
1100+ <tr><th colspan="4" class="header">Existing Keywords</th></tr>
1101+ <tr tal:define="keywords db/keyword/list"
1102+ tal:repeat="start python:range(0, len(keywords), 4)">
1103+ <td tal:define="batch python:utils.Batch(keywords, 4, start)"
1104+ tal:repeat="keyword batch" tal:content="keyword/name">keyword here</td>
1105+ </tr>
1106+ <tr><td colspan="4" style="border-top: 1px solid gray"> </td></tr>
1107+ </table>
1108+
1109+ ... which will produce a table with four columns containing the items of the
1110+ "keyword" class (well, their "name" anyway).
1111+
10131112Displaying Properties
10141113---------------------
10151114
0 commit comments