Mercurial > p > roundup > code
annotate doc/templating.txt @ 2119:cc4667ef3f12
Added the ability to toggle where error messages go.
They either go to the user (default, for backwards compatibility), the
dispatcher, or both. These are able to be toggled via settings in config.py.
Please refer to upgrading.txt for more details. (And Richard, let me know
if I've done anything wrong with this checkin. :))
| author | Eddie Parker <eparker@users.sourceforge.net> |
|---|---|
| date | Thu, 25 Mar 2004 19:27:15 +0000 |
| parents | 43ab730ee194 |
| children | 6535aa11418a |
| rev | line source |
|---|---|
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 ========================== |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 HTML Templating Mechanisms |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 ========================== |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
5 :Version: $Revision: 1.14 $ |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 Current Situation and Issues |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 ============================ |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 Syntax |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 ------ |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 Roundup currently uses an element-based HTML-tag-alike templating syntax:: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 <display call="checklist('status')"> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 The templates were initially parsed using recursive regular expression |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
18 parsing, and since no template tag could encapsulate itself, the parser |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 worked just fine. Then we got the ``<require>`` tag, which could have other |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 ``<require>`` tags inside. This forced us to move towards a more complete |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 parser, using the standard python sgmllib/htmllib parser. The downside of this |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 switch is that constructs of the form:: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 <tr class="row-<display call="plain('status')">"> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
26 don't parse as we'd hope. We can modify the parser to work, but that doesn't |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
27 another couple of issues that have arisen: |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 |
| 956 | 29 1. the template syntax is not well-formed, and therefore is a pain to parse |
| 30 and doesn't play well with other tools, and | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 2. user requirements generally have to be anticipated and accounted for in |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 templating functions (like ``plain()`` and ``checklist()`` above), and |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 we are therefore artificially restrictive. |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 Arguments for switching templating systems: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 *Pros* |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 - more flexibility in templating control and content |
| 956 | 40 - we can be well-formed |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 *Cons* |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 - installed user base (though they'd have to edit their templates with the |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 next release anyway) |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 - current templating system is pretty trivial, and a more flexible system |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 is likely to be more complex |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
50 Templates |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 --------- |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 |
| 957 | 53 We should also take this opportunity to open up the flexibility of the |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 templates through: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
56 1. allowing the tracker to define a "page" template, which holds the overall |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 page structure, including header and footer |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
59 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 Possible approaches |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 =================== |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 Zope's PageTemplates |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 -------------------- |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 Using Zope's PageTemplates seems to be the best approach of the lot. |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
68 In my opinion, it's the peak of HTML templating technology at present. With |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
69 appropriate infrastructure, the above two examples would read: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 <span tal:replace="item/status/checklist">status checklist</span> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 <tr tal:attributes="class string:row-${item/status/name}"> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 ... which doesn't look that much more complicated... honest... |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
76 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
77 Other fun can be had when you start playing with stuff like: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 <table> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 <tr tal:repeat="message item/msg/list"> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 <td tal:define="from message/from"> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 <a href="" tal:attributes="href string:mailto:${from/address}" |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 tal:content="from/name">mailto link</a> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 </td> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
85 <td tal:content="message/title">subject</td> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
86 <td tal:content="message/created">received date</td> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
87 </tr> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
88 </table> |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
89 |
| 963 | 90 Note: even if we don't switch templating as a whole, this document may be |
| 91 applied to the ZRoundup frontend. | |
| 92 | |
| 960 | 93 PageTemplates in a Nutshell |
| 94 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| 95 | |
| 96 PageTemplates consist of three technologies: | |
| 97 | |
| 98 TAL - Template Attribute Language | |
| 99 This is the syntax which is woven into the HTML using the ``tal:`` tag | |
| 100 attributes. A TAL parser pulls out the TAL commands from the attributes | |
| 101 runs them using some expression engine. | |
| 102 | |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
103 TALES - TAL Expression Syntax |
| 960 | 104 The expression engine used in this case is TALES, which runs the expressions |
| 105 that form the tag attribute values. TALES expressions come in three | |
| 106 flavours: | |
| 107 | |
|
961
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
108 Path Expressions - eg. ``item/status/checklist`` |
| 960 | 109 These are object attribute / item accesses. Roughly speaking, the path |
|
961
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
110 ``item/status/checklist`` is broken into parts ``item``, ``status`` |
|
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
111 and ``checklist``. The ``item`` part is the root of the expression. |
|
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
112 We then look for a ``status`` attribute on ``item``, or failing that, a |
|
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
113 ``status`` item (as in ``item['status']``). If that |
| 960 | 114 fails, the path expression fails. When we get to the end, the object we're |
| 115 left with is evaluated to get a string - methods are called, objects are | |
| 116 stringified. Path expressions may have an optional ``path:`` prefix, though | |
| 117 they are the default expression type, so it's not necessary. | |
| 118 | |
| 119 String Expressions - eg. ``string:hello ${user/name}`` | |
| 120 These expressions are simple string interpolations (though they can be just | |
| 121 plain strings with no interpolation if you want. The expression in the | |
| 122 ``${ ... }`` is just a path expression as above. | |
| 123 | |
| 124 Python Expressions - eg. ``python: 1+1`` | |
| 125 These expressions give the full power of Python. All the "root level" | |
|
961
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
126 variables are available, so ``python:item.status.checklist()`` would be |
|
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
127 equivalent to ``item/status/checklist``, assuming that ``checklist`` is |
|
7d68f88f0642
more useful example
Richard Jones <richard@users.sourceforge.net>
parents:
960
diff
changeset
|
128 a method. |
| 960 | 129 |
| 130 PageTemplates | |
| 131 The PageTemplates module glues together TAL and TALES. | |
| 132 | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
133 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
134 Implementation |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
135 ~~~~~~~~~~~~~~ |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
136 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
137 I'm envisaging an infrastructure layer where each template has the following |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
138 "root level" (that is, directly accessible in the TALES namespace) variables |
| 960 | 139 defined: |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
140 |
|
991
79129f013153
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
978
diff
changeset
|
141 *klass* |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
142 The current class of item being displayed as an HTMLClass instance. Name is |
|
991
79129f013153
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
978
diff
changeset
|
143 mangled so it can be used in Python expressions. |
| 963 | 144 |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 *item* |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
146 The current item from the database, if we're viewing a specific item, as an |
| 963 | 147 HTMLItem instance. If it doesn't exist, then we're on a new item page. |
| 148 | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
149 (*classname*) |
| 963 | 150 this is one of two things: |
| 151 | |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
152 1. the *item* is also available under its classname, so a *user* item |
| 963 | 153 would also be available under the name *user*. This is also an HTMLItem |
| 154 instance. | |
| 155 2. if there's no *item* then the current class is available through this | |
| 156 name, thus "user/name" and "user/name/menu" will still work - the latter | |
| 157 will pull information from the form if it can. | |
| 158 | |
| 978 | 159 this is a dangerous attribute, and may cause us pain the long run (its name |
| 160 may clash with other top-level variables ... it already clashed with the | |
| 161 proposed *user* variable). It might be safer to go with just *class* and | |
| 162 *item*, actually... | |
| 163 | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
164 *form* |
| 963 | 165 The current CGI form information as a mapping of form argument name to value |
| 166 | |
| 167 *request* | |
| 168 Includes information about the current request, including: | |
| 169 - the url | |
| 170 - the current index information (``filterspec``, ``filter`` args, | |
| 171 ``properties``, etc) parsed out of the form. | |
| 172 - methods for easy filterspec link generation | |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
173 - *user*, the current user item as an HTMLItem instance |
| 963 | 174 |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
175 *tracker* |
|
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
176 The current tracker |
| 963 | 177 |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
178 *db* |
| 963 | 179 The current open database |
| 180 | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
181 *config* |
| 963 | 182 The current instance config |
| 183 | |
| 960 | 184 *modules* |
| 963 | 185 python modules made available (XXX: not sure what's actually in there tho) |
| 186 | |
|
991
79129f013153
*** empty log message ***
Richard Jones <richard@users.sourceforge.net>
parents:
978
diff
changeset
|
187 Accesses through a class (either through *klass* or *db.<classname>*):: |
| 958 | 188 |
| 959 | 189 class HTMLClass: |
| 958 | 190 def __getattr__(self, attr): |
| 191 ''' return an HTMLItem instance ''' | |
| 192 def classhelp(self, ...) | |
| 193 def list(self, ...) | |
| 966 | 194 def filter(self): |
| 195 ''' Return a list of items from this class, filtered and sorted | |
| 196 by the current requested filterspec/filter/sort/group args | |
| 197 ''' | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
198 |
| 958 | 199 Accesses through an *item*:: |
| 200 | |
| 201 class HTMLItem: | |
| 202 def __getattr__(self, attr): | |
| 203 ''' return an HTMLItem instance ''' | |
| 204 def history(self, ...) | |
| 205 def remove(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
206 |
| 963 | 207 Note: the above could cause problems if someone wants to have properties |
| 208 called "history" or "remove"... | |
| 209 | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
210 String, Number, Date, Interval HTMLProperty |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
211 a wrapper object which may be stringified for the current plain() behaviour |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
212 and has methods emulating all the current display functions, so |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
213 ``item/name/plain`` would emulate the current ``call="plain()``". Also, |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
214 ``python:item.name.plain(name=value)`` would work just fine:: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
215 |
| 958 | 216 class HTMLProperty: |
| 217 def __init__(self, instance, db, ...) | |
| 218 def __str__(self): | |
| 219 return self.plain() | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
220 |
| 958 | 221 class StringHTMLProperty(HTLProperty): |
| 222 def plain(self, ...) | |
| 223 def field(self, ...) | |
| 224 def stext(self, ...) | |
| 225 def multiline(self, ...) | |
| 226 def email(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
227 |
| 958 | 228 class NumberHTMLProperty(HTMLProperty): |
| 229 def plain(self, ...) | |
| 230 def field(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
231 |
| 958 | 232 class BooleanHTMLProperty(HTMLProperty): |
| 233 def plain(self, ...) | |
| 234 def field(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
235 |
| 958 | 236 class DateHTMLProperty(HTMLProperty): |
| 237 def plain(self, ...) | |
| 238 def field(self, ...) | |
| 239 def reldate(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
240 |
| 958 | 241 class IntervalHTMLProperty(HTMLProperty): |
| 242 def plain(self, ...) | |
| 243 def field(self, ...) | |
| 963 | 244 def pretty(self, ...) |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
245 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
246 Link HTMLProperty |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
247 the wrapper object would include the above as well as being able to access |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
248 the class information. Stringifying the object itself would result in the |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
249 value from the item being displayed. Accessing attributes of this object |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
250 would result in the appropriate entry from the class being queried for the |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
251 property accessed (so item/assignedto/name would look up the user entry |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
252 identified by the assignedto property on item, and then the name property of |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
253 that user):: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
254 |
| 958 | 255 class LinkHTMLProperty(HTMLProperty): |
| 256 ''' Be a HTMLItem too ''' | |
| 257 def __getattr__(self, attr): | |
| 258 ''' return a new HTMLProperty ''' | |
| 259 def download(self, ...) | |
| 260 def checklist(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
261 |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
262 Multilink HTMLProperty |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
263 the wrapper would also be iterable, returning a wrapper object like the Link |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
264 case for each entry in the multilink:: |
|
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
265 |
| 958 | 266 class MultilinkHTMLProperty(HTMLProperty): |
| 267 def __len__(self): | |
| 268 ''' length of the multilink ''' | |
| 269 def __getitem(self, num): | |
| 270 ''' return a new HTMLItem ''' | |
| 271 def checklist(self, ...) | |
| 272 def list(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
273 |
| 963 | 274 *request* |
| 275 the request object will handle:: | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
276 |
| 963 | 277 class Request: |
| 958 | 278 def __init__(self, ...) |
| 279 def filterspec(self, ...) | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
280 |
| 978 | 281 Accesses through the *user* attribute of *request*:: |
| 282 | |
| 283 class HTMLUser(HTMLItem): | |
| 284 def hasPermission(self, ...) | |
| 285 | |
| 286 (note that the other permission check implemented by the security module may | |
| 287 be implemented easily in a tal:condition, so isn't needed here) | |
| 288 | |
| 966 | 289 Template files |
| 290 ~~~~~~~~~~~~~~ | |
| 291 | |
| 292 Each instance will have the opportunity to supply the following templates: | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
293 |
| 966 | 294 page |
| 295 This is the overall page look template, and includes at some point a TAL | |
| 296 command that includes the variable "content". This variable causes the actual | |
| 297 page content to be generated. | |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
298 |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
299 [classname].[template type] |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
300 Templates that have this form are applied to item data. There are three forms |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
301 of special template types: |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
302 |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
303 [classname].index |
|
1089
43ab730ee194
instance -> tracker, node -> item
Richard Jones <richard@users.sourceforge.net>
parents:
991
diff
changeset
|
304 This template is used when the URL specifies only the class, and not an item |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
305 designator. It displays a list of [classname] items from the database, and |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
306 a "filter refinement" form. |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
307 Would perform a TAL ``repeat`` command using the list supplied by |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
308 ``class/filter``. This deviates from the current situation in that currently |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
309 the index template specifies a single row, and the filter part is |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
310 automatically generated. |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
311 |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
312 [classname].item |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
313 This template is used when the URL specifies an item designator. It's the |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
314 default template used (when no template is explicitly given). It displays |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
315 a single item from the database using the *classname* variable (that |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
316 is, the variable of the same name as the class being displayed. If |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
317 |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
318 These two special template types may be overridden by the :template CGI |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
319 variable. |
| 966 | 320 |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
321 Note that the "newitem" template doesn't exist any more because the item |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
322 templates may determine whether the page has an existing item to render. The |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
323 new item page would be accessed by "/tracker/url/issue?:template=item". |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
324 The old "filter" template has been subsumed by the index template. |
|
955
84281f7f2900
templating redesign
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
325 |
| 958 | 326 |
| 966 | 327 Integrating Code |
| 328 ~~~~~~~~~~~~~~~~ | |
| 329 | |
| 330 We will install PageTemplates, TAL and ZTUtils in site-packages. If there is a | |
| 331 local Zope installation, it will use its own PageTemplates code (Zope modifies | |
| 332 the module search path to give precedence to its own module library). | |
| 333 | |
| 334 We will then install the trivial MultiMapping and ComputedAttribute modules in | |
| 335 the Roundup package, and have some import trickery that determines whether | |
| 336 they are required, and if so they will be imported as if they were at the | |
| 337 "top level" of the module namespace. | |
| 338 | |
|
977
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
339 New CGI client structure |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
340 ~~~~~~~~~~~~~~~~~~~~~~~~ |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
341 |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
342 Handling of a request in the CGI client will take three phases: |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
343 |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
344 1. Determine user, pre-set "content" to authorisation page if necessary |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
345 2. Render main page, with callback to "content" |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
346 3. Render content - if not pre-set, then determine which content to render |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
347 |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
348 |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
349 Use Cases |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
350 ~~~~~~~~~ |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
351 |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
352 Meta/parent bug |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
353 Can be done with addition to the schema and then the actual parent heirarchy |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
354 may be displayed with a new template page ":dependencies" or something. |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
355 |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
356 Submission wizard |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
357 Can be done using new templates ":page1", ":page2", etc and some additional |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
358 actions on the CGI Client class in the instance. |
|
22e6707a993a
More tweaks to the design.
Richard Jones <richard@users.sourceforge.net>
parents:
966
diff
changeset
|
359 |
