22HTML Templating Mechanisms
33==========================
44
5- :Version: $Revision: 1.8 $
5+ :Version: $Revision: 1.9 $
66
77Current Situation and Issues
88============================
@@ -89,6 +89,9 @@ Other fun can be had when you start playing with stuff like:
8989 </tr>
9090 </table>
9191
92+ Note: even if we don't switch templating as a whole, this document may be
93+ applied to the ZRoundup frontend.
94+
9295PageTemplates in a Nutshell
9396~~~~~~~~~~~~~~~~~~~~~~~~~~~
9497
@@ -138,28 +141,54 @@ I'm envisaging an infrastructure layer where each template has the following
138141defined:
139142
140143*user*
141- the current user node as an HTMLItem instance
144+ The current user node as an HTMLItem instance
145+
142146*class*
143- the current class of node being displayed as an HTMLClass instance
147+ The current class of node being displayed as an HTMLClass instance
148+
144149*item*
145- the current node from the database, if we're viewing a specific node, as an
146- HTMLItem instance
150+ The current node from the database, if we're viewing a specific node, as an
151+ HTMLItem instance. If it doesn't exist, then we're on a new item page.
152+
147153(*classname*)
148- the current node is also available under its classname, so a *user* node
149- would also be available under the name *user*. This is also an HTMLItem
150- instance.
154+ this is one of two things:
155+
156+ 1. the *item* is also available under its classname, so a *user* node
157+ would also be available under the name *user*. This is also an HTMLItem
158+ instance.
159+ 2. if there's no *item* then the current class is available through this
160+ name, thus "user/name" and "user/name/menu" will still work - the latter
161+ will pull information from the form if it can.
162+
151163*form*
152- 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
165+
166+ *request*
167+ Includes information about the current request, including:
168+ - the url
169+ - the current index information (``filterspec``, ``filter`` args,
170+ ``properties``, etc) parsed out of the form.
171+ - methods for easy filterspec link generation
172+
153173*instance*
154- the current instance
174+ The current instance
175+
155176*db*
156- the current open database
177+ The current open database
178+
157179*config*
158- the current instance config
159- *util*
160- utility methods
180+ The current instance config
181+
161182*modules*
162- Python modules made available (XXX: not sure what's actually in there tho)
183+ python modules made available (XXX: not sure what's actually in there tho)
184+
185+ Accesses through the *user*::
186+
187+ class HTMLUser:
188+ def hasPermission(self, ...)
189+
190+ (note that the other permission check implemented by the security module may
191+ be implemented easily in a tal:condition, so isn't needed here)
163192
164193Accesses through a class (either through *class* or *db.<classname>*):
165194
@@ -175,9 +204,11 @@ Accesses through an *item*::
175204 def __getattr__(self, attr):
176205 ''' return an HTMLItem instance '''
177206 def history(self, ...)
178- def classhelp(self, ...)
179207 def remove(self, ...)
180208
209+ Note: the above could cause problems if someone wants to have properties
210+ called "history" or "remove"...
211+
181212String, Number, Date, Interval HTMLProperty
182213 a wrapper object which may be stringified for the current plain() behaviour
183214 and has methods emulating all the current display functions, so
@@ -212,6 +243,7 @@ String, Number, Date, Interval HTMLProperty
212243 class IntervalHTMLProperty(HTMLProperty):
213244 def plain(self, ...)
214245 def field(self, ...)
246+ def pretty(self, ...)
215247
216248Link HTMLProperty
217249 the wrapper object would include the above as well as being able to access
@@ -241,14 +273,12 @@ Multilink HTMLProperty
241273 def checklist(self, ...)
242274 def list(self, ...)
243275
244- *util *
245- the util object will handle::
276+ *request *
277+ the request object will handle::
246278
247- class Util :
279+ class Request :
248280 def __init__(self, ...)
249281 def filterspec(self, ...)
250- def note(self, ...)
251- def submit(self, ...)
252282
253283Action
254284======
0 commit comments