Mercurial > p > roundup > code
comparison doc/templating.txt @ 978:4f57a8f51da4
tweaks
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 27 Aug 2002 08:34:32 +0000 |
| parents | 22e6707a993a |
| children | 79129f013153 |
comparison
equal
deleted
inserted
replaced
| 977:22e6707a993a | 978:4f57a8f51da4 |
|---|---|
| 1 ========================== | 1 ========================== |
| 2 HTML Templating Mechanisms | 2 HTML Templating Mechanisms |
| 3 ========================== | 3 ========================== |
| 4 | 4 |
| 5 :Version: $Revision: 1.11 $ | 5 :Version: $Revision: 1.12 $ |
| 6 | 6 |
| 7 Current Situation and Issues | 7 Current Situation and Issues |
| 8 ============================ | 8 ============================ |
| 9 | 9 |
| 10 Syntax | 10 Syntax |
| 136 | 136 |
| 137 I'm envisaging an infrastructure layer where each template has the following | 137 I'm envisaging an infrastructure layer where each template has the following |
| 138 "root level" (that is, directly accessible in the TALES namespace) variables | 138 "root level" (that is, directly accessible in the TALES namespace) variables |
| 139 defined: | 139 defined: |
| 140 | 140 |
| 141 *user* | |
| 142 The current user node as an HTMLItem instance | |
| 143 | |
| 144 *class* | 141 *class* |
| 145 The current class of node being displayed as an HTMLClass instance | 142 The current class of node being displayed as an HTMLClass instance |
| 146 | 143 |
| 147 *item* | 144 *item* |
| 148 The current node from the database, if we're viewing a specific node, as an | 145 The current node from the database, if we're viewing a specific node, as an |
| 156 instance. | 153 instance. |
| 157 2. if there's no *item* then the current class is available through this | 154 2. if there's no *item* then the current class is available through this |
| 158 name, thus "user/name" and "user/name/menu" will still work - the latter | 155 name, thus "user/name" and "user/name/menu" will still work - the latter |
| 159 will pull information from the form if it can. | 156 will pull information from the form if it can. |
| 160 | 157 |
| 158 this is a dangerous attribute, and may cause us pain the long run (its name | |
| 159 may clash with other top-level variables ... it already clashed with the | |
| 160 proposed *user* variable). It might be safer to go with just *class* and | |
| 161 *item*, actually... | |
| 162 | |
| 161 *form* | 163 *form* |
| 162 The current CGI form information as a mapping of form argument name to value | 164 The current CGI form information as a mapping of form argument name to value |
| 163 | 165 |
| 164 *request* | 166 *request* |
| 165 Includes information about the current request, including: | 167 Includes information about the current request, including: |
| 166 - the url | 168 - the url |
| 167 - the current index information (``filterspec``, ``filter`` args, | 169 - the current index information (``filterspec``, ``filter`` args, |
| 168 ``properties``, etc) parsed out of the form. | 170 ``properties``, etc) parsed out of the form. |
| 169 - methods for easy filterspec link generation | 171 - methods for easy filterspec link generation |
| 172 - *user*, the current user node as an HTMLItem instance | |
| 170 | 173 |
| 171 *instance* | 174 *instance* |
| 172 The current instance | 175 The current instance |
| 173 | 176 |
| 174 *db* | 177 *db* |
| 178 The current instance config | 181 The current instance config |
| 179 | 182 |
| 180 *modules* | 183 *modules* |
| 181 python modules made available (XXX: not sure what's actually in there tho) | 184 python modules made available (XXX: not sure what's actually in there tho) |
| 182 | 185 |
| 183 Accesses through the *user*:: | 186 Accesses through a class (either through *class* or *db.<classname>*):: |
| 184 | |
| 185 class HTMLUser: | |
| 186 def hasPermission(self, ...) | |
| 187 | |
| 188 (note that the other permission check implemented by the security module may | |
| 189 be implemented easily in a tal:condition, so isn't needed here) | |
| 190 | |
| 191 Accesses through a class (either through *class* or *db.<classname>*): | |
| 192 | 187 |
| 193 class HTMLClass: | 188 class HTMLClass: |
| 194 def __getattr__(self, attr): | 189 def __getattr__(self, attr): |
| 195 ''' return an HTMLItem instance ''' | 190 ''' return an HTMLItem instance ''' |
| 196 def classhelp(self, ...) | 191 def classhelp(self, ...) |
| 280 | 275 |
| 281 class Request: | 276 class Request: |
| 282 def __init__(self, ...) | 277 def __init__(self, ...) |
| 283 def filterspec(self, ...) | 278 def filterspec(self, ...) |
| 284 | 279 |
| 280 Accesses through the *user* attribute of *request*:: | |
| 281 | |
| 282 class HTMLUser(HTMLItem): | |
| 283 def hasPermission(self, ...) | |
| 284 | |
| 285 (note that the other permission check implemented by the security module may | |
| 286 be implemented easily in a tal:condition, so isn't needed here) | |
| 287 | |
| 285 Template files | 288 Template files |
| 286 ~~~~~~~~~~~~~~ | 289 ~~~~~~~~~~~~~~ |
| 287 | 290 |
| 288 Each instance will have the opportunity to supply the following templates: | 291 Each instance will have the opportunity to supply the following templates: |
| 289 | 292 |
