Skip to content

Commit 9c88afd

Browse files
author
Richard Jones
committed
More documentation.
Simplified the "klass", "item" and "*classname*" variables into "context.
1 parent e2ac797 commit 9c88afd

File tree

13 files changed

+187
-115
lines changed

13 files changed

+187
-115
lines changed

TODO.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pending admin: have roundup-admin "set" command be applicable to all items
5353
in a class
5454

5555
bug: request.url is incorrect in cgi-bin environments
56-
56+
bug: query editing not translated to new templating
5757

5858
done web: Re-enable link backrefs from messages (feature request #568714)
5959
done web: have the page layout (header/footer) be templatable

doc/customizing.txt

Lines changed: 100 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Customising Roundup
33
===================
44

5-
:Version: $Revision: 1.19 $
5+
:Version: $Revision: 1.20 $
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
@@ -591,6 +591,9 @@ control on to the instance interfaces.Client class which handles the rest of
591591
the access through its main() method. This means that you can do pretty much
592592
anything you want as a web interface to your instance.
593593

594+
Figuring out what is displayed
595+
::::::::::::::::::::::::::::::
596+
594597
Most customisation of the web view can be done by modifying the templates in
595598
the instance **html** directory. There are several types of files in there:
596599

@@ -615,6 +618,9 @@ user.register
615618
style.css
616619
a static file that is served up as-is
617620

621+
How requests are processed
622+
::::::::::::::::::::::::::
623+
618624
The basic processing of a web request proceeds as follows:
619625

620626
1. figure out who we are, defaulting to the "anonymous" user
@@ -636,6 +642,9 @@ In some situations, exceptions occur:
636642
- NotFound (raised wherever it needs to be)
637643
this exception percolates up to the CGI interface that called the client
638644

645+
Determining web context
646+
:::::::::::::::::::::::
647+
639648
To determine the "context" of a request, we look at the URL and the special
640649
request variable ``:template``. The URL path after the instance identifier
641650
is examined. Typical URL paths look like:
@@ -679,8 +688,14 @@ which defaults to:
679688
- only classname suplied: "index"
680689
- full item designator supplied: "item"
681690

682-
Actions are triggered by using a ``:action`` CGI variable, where the value is
683-
one of:
691+
692+
Performing actions in web requests
693+
::::::::::::::::::::::::::::::::::
694+
695+
When a user requests a web page, they may optionally also request for an
696+
action to take place. As described in `how requests are processed`_, the
697+
action is performed before the requested page is generated. Actions are
698+
triggered by using a ``:action`` CGI variable, where the value is one of:
684699

685700
login
686701
Attempt to log a user in.
@@ -910,6 +925,83 @@ TALES - TAL Expression Syntax
910925
equivalent to ``item/status/checklist``, assuming that ``checklist`` is
911926
a method.
912927

928+
Information available to templates
929+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
930+
931+
The following variables are available to templates.
932+
933+
.. taken from roundup.cgi.templating.RoundupPageTemplate docstring
934+
935+
*context*
936+
The current context. This is either None, a wrapper around a
937+
hyperdb class (an HTMLClass) or a wrapper around a hyperdb item (an
938+
HTMLItem).
939+
*request*
940+
Includes information about the current request, including:
941+
- the url
942+
- the current index information (``filterspec``, ``filter`` args,
943+
``properties``, etc) parsed out of the form.
944+
- methods for easy filterspec link generation
945+
- *user*, the current user node as an HTMLItem instance
946+
- *form*
947+
The current CGI form information as a mapping of form argument
948+
name to value
949+
*instance*
950+
The current instance
951+
*db*
952+
The current database, through which db.config may be reached.
953+
954+
The context variable
955+
::::::::::::::::::
956+
957+
The *context* variable is one of three things based on the current context
958+
(see `determining web context`_ for how we figure this out):
959+
960+
1. if we're looking at a "home" page, then it's None
961+
2. if we're looking at a specific hyperdb class, it's an HTMLClass instance
962+
3. if we're looking at a specific hyperdb item, it's an HTMLItem instance
963+
964+
If the context is not None, we can access the properties of the class or item.
965+
The only real difference between cases 2 and 3 above are:
966+
967+
1. the properties may have a real value behind them, and this will appear if
968+
the property is displayed through ``context/property`` or
969+
``context/property/field``.
970+
2. the context's "id" property will be a false value in the second case, but
971+
a real, or true value in the third. Thus we can determine whether we're
972+
looking at a real item from the hyperdb by testing "context/id".
973+
974+
975+
The request variable
976+
::::::::::::::::::::
977+
978+
The request variable is packed with information about the current request.
979+
980+
.. taken from roundup.cgi.templating.HTMLRequest docstring
981+
982+
=========== ================================================================
983+
Variable Holds
984+
=========== ================================================================
985+
form the CGI form as a cgi.FieldStorage
986+
env the CGI environment variables
987+
url the current URL path for this request
988+
base the base URL for this instance
989+
user a HTMLUser instance for this user
990+
classname the current classname (possibly None)
991+
template the current template (suffix, also possibly None)
992+
form the current CGI form variables in a FieldStorage
993+
**Index page specific variables (indexing arguments)**
994+
columns dictionary of the columns to display in an index page
995+
show a convenience access to columns - request/show/colname will
996+
be true if the columns should be displayed, false otherwise
997+
sort index sort column (direction, column name)
998+
group index grouping property (direction, column name)
999+
filter properties to filter the index on
1000+
filterspec values to filter the index on
1001+
search_text text to perform a full-text search on for an index
1002+
----------- ----------------------------------------------------------------
1003+
1004+
9131005
Displaying Properties
9141006
~~~~~~~~~~~~~~~~~~~~~
9151007

@@ -931,11 +1023,11 @@ An index view specifier (URL fragment) looks like this (whitespace has been
9311023
added for clarity)::
9321024

9331025
/issue?status=unread,in-progress,resolved&
934-
topic=security,ui&
935-
:group=+priority&
936-
:sort=-activity&
937-
:filters=status,topic&
938-
:columns=title,status,fixer
1026+
topic=security,ui&
1027+
:group=+priority&
1028+
:sort=-activity&
1029+
:filters=status,topic&
1030+
:columns=title,status,fixer
9391031

9401032
The index view is determined by two parts of the specifier: the layout part and
9411033
the filter part. The layout part consists of the query parameters that begin
@@ -958,10 +1050,6 @@ by activity, arranged in descending order. The filter section shows filters for
9581050
the "status" and "topic" properties, and the table includes columns for the
9591051
"title", "status", and "fixer" properties.
9601052

961-
Associated with each item class is a default layout specifier. The layout
962-
specifier in the above example is the default layout to be provided with the
963-
default bug-tracker schema described above in section 4.4.
964-
9651053
Filtering of indexes
9661054
::::::::::::::::::::
9671055

roundup/cgi/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.20 2002-09-06 22:54:51 richard Exp $
1+
# $Id: client.py,v 1.21 2002-09-09 00:45:06 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -1069,10 +1069,8 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
10691069
must be supplied or a ValueError will be raised.
10701070
'''
10711071
required = []
1072-
print form.keys()
10731072
if form.has_key(':required'):
10741073
value = form[':required']
1075-
print 'required', value
10761074
if isinstance(value, type([])):
10771075
required = [i.value.strip() for i in value]
10781076
else:

roundup/cgi/templating.py

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -123,47 +123,28 @@ class RoundupPageTemplate(PageTemplate.PageTemplate):
123123
Interrogate the client to set up the various template variables to
124124
be available:
125125
126-
*class*
127-
The current class of node being displayed as an HTMLClass
128-
instance.
129-
*item*
130-
The current node from the database, if we're viewing a specific
131-
node, as an HTMLItem instance. If it doesn't exist, then we're
132-
on a new item page.
133-
(*classname*)
134-
this is one of two things:
135-
136-
1. the *item* is also available under its classname, so a *user*
137-
node would also be available under the name *user*. This is
138-
also an HTMLItem instance.
139-
2. if there's no *item* then the current class is available
140-
through this name, thus "user/name" and "user/name/menu" will
141-
still work - the latter will pull information from the form
142-
if it can.
143-
*form*
144-
The current CGI form information as a mapping of form argument
145-
name to value
126+
*context*
127+
this is one of three things:
128+
1. None - we're viewing a "home" page
129+
2. The current class of item being displayed. This is an HTMLClass
130+
instance.
131+
3. The current item from the database, if we're viewing a specific
132+
item, as an HTMLItem instance.
146133
*request*
147134
Includes information about the current request, including:
148135
- the url
149136
- the current index information (``filterspec``, ``filter`` args,
150137
``properties``, etc) parsed out of the form.
151138
- methods for easy filterspec link generation
152139
- *user*, the current user node as an HTMLItem instance
140+
- *form*, the current CGI form information as a FieldStorage
153141
*instance*
154142
The current instance
155143
*db*
156144
The current database, through which db.config may be reached.
157-
158-
Maybe also:
159-
160-
*modules*
161-
python modules made available (XXX: not sure what's actually in
162-
there tho)
163145
'''
164146
def getContext(self, client, classname, request):
165147
c = {
166-
'klass': HTMLClass(client, classname),
167148
'options': {},
168149
'nothing': None,
169150
'request': request,
@@ -173,10 +154,9 @@ def getContext(self, client, classname, request):
173154
}
174155
# add in the item if there is one
175156
if client.nodeid:
176-
c['item'] = HTMLItem(client, classname, client.nodeid)
177-
c[classname] = c['item']
157+
c['context'] = HTMLItem(client, classname, client.nodeid)
178158
else:
179-
c[classname] = c['klass']
159+
c['context'] = HTMLClass(client, classname)
180160
return c
181161

182162
def render(self, client, classname, request, **options):
@@ -237,11 +217,15 @@ def __getitem__(self, item):
237217
''' return an HTMLProperty instance
238218
'''
239219
#print 'getitem', (self, item)
220+
221+
# we don't exist
222+
if item == 'id':
223+
return None
240224
if item == 'creator':
241-
return HTMLUser(self.client, 'user', client.userid)
225+
# but we will be created by this user...
226+
return HTMLUser(self.client, 'user', self.client.userid)
242227

243-
if not self.props.has_key(item):
244-
raise KeyError, item
228+
# get the property
245229
prop = self.props[item]
246230

247231
# look up the correct HTMLProperty class
@@ -398,8 +382,8 @@ def __getitem__(self, item):
398382
#print 'getitem', (self, item)
399383
if item == 'id':
400384
return self.nodeid
401-
if not self.props.has_key(item):
402-
raise KeyError, item
385+
386+
# get the property
403387
prop = self.props[item]
404388

405389
# get the value, handling missing values

roundup/templates/classic/html/_generic.index

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</p>
2020

2121
<form onSubmit="return submit_once()" method="POST">
22-
<textarea rows="15" cols="60" name="rows" tal:content="klass/csv"></textarea>
22+
<textarea rows="15" cols="60" name="rows" tal:content="context/csv"></textarea>
2323
<br>
2424
<input type="hidden" name=":action" value="editCSV">
2525
<input type="submit" value="Edit Items">

roundup/templates/classic/html/file.index

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- dollarId: file.index,v 1.4 2002/01/23 05:10:27 richard Exp dollar-->
2-
<tr tal:repeat="file class/list">
2+
<tr tal:repeat="file context/list">
33
<td tal:condition="display/properties/name">
44
<a href="" tal:attributes="href string:file${file/id}/${file/name}">dld link</a>
55
</td>

roundup/templates/classic/html/issue.index

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<td>
6060
<select name=":sort">
6161
<option value="">- nothing -</option>
62-
<option tal:repeat="col klass/properties"
62+
<option tal:repeat="col context/properties"
6363
tal:attributes="value col/name;
6464
selected python:col.name == request.sort[1]"
6565
tal:content="col/name">column</option>
@@ -75,7 +75,7 @@
7575
<td>
7676
<select name=":group">
7777
<option value="">- nothing -</option>
78-
<option tal:repeat="col klass/properties"
78+
<option tal:repeat="col context/properties"
7979
tal:attributes="value col/name;
8080
selected python:col.name == request.group[1]"
8181
tal:content="col/name">column</option>

0 commit comments

Comments
 (0)