comparison doc/customizing.txt @ 1124:1fc1f92c5f31

more doc, bugfix in Batch
author Richard Jones <richard@users.sourceforge.net>
date Thu, 12 Sep 2002 03:33:04 +0000
parents 644d3075c2df
children 3c1533be3822
comparison
equal deleted inserted replaced
1123:644d3075c2df 1124:1fc1f92c5f31
1 =================== 1 ===================
2 Customising Roundup 2 Customising Roundup
3 =================== 3 ===================
4 4
5 :Version: $Revision: 1.29 $ 5 :Version: $Revision: 1.30 $
6 6
7 .. This document borrows from the ZopeBook section on ZPT. The original is at: 7 .. This document borrows from the ZopeBook section on ZPT. The original is at:
8 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx 8 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
9 9
10 .. contents:: 10 .. contents::
946 =========== ============================================================= 946 =========== =============================================================
947 Method Description 947 Method Description
948 =========== ============================================================= 948 =========== =============================================================
949 plain render a "plain" representation of the property 949 plain render a "plain" representation of the property
950 field render a form edit field for the property 950 field 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
952 property as StructuredText (requires the StructureText module 952 property as StructuredText (requires the StructureText module
953 to be installed separately) 953 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
955 field for the property 955 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
957 property as an obscured email address 957 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
958 =========== ============================================================= 966 =========== =============================================================
959
960 XXX do the other properties
961 967
962 The request variable 968 The request variable
963 ~~~~~~~~~~~~~~~~~~~~ 969 ~~~~~~~~~~~~~~~~~~~~
964 970
965 Note: this is implemented by the roundup.cgi.templating.HTMLRequest class. 971 Note: this is implemented by the roundup.cgi.templating.HTMLRequest class.
994 filter properties to filter the index on 1000 filter properties to filter the index on
995 filterspec values to filter the index on 1001 filterspec values to filter the index on
996 search_text text to perform a full-text search on for an index 1002 search_text text to perform a full-text search on for an index
997 =========== ================================================================ 1003 =========== ================================================================
998 1004
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
999 The db variable 1021 The db variable
1000 ~~~~~~~~~~~~~~~ 1022 ~~~~~~~~~~~~~~~
1001 1023
1002 Note: this is implemented by the roundup.cgi.templating.HTMLDatabase class. 1024 Note: this is implemented by the roundup.cgi.templating.HTMLDatabase class.
1003 1025
1007 db/user 1029 db/user
1008 python:db.user 1030 python:db.user
1009 1031
1010 The access results in a `hyperdb class wrapper`_. 1032 The access results in a `hyperdb class wrapper`_.
1011 1033
1034
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">&nbsp;</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).
1012 1111
1013 Displaying Properties 1112 Displaying Properties
1014 --------------------- 1113 ---------------------
1015 1114
1016 Properties appear in the user interface in three contexts: in indices, in 1115 Properties appear in the user interface in three contexts: in indices, in

Roundup Issue Tracker: http://roundup-tracker.org/