Skip to content

Commit ce31076

Browse files
author
Richard Jones
committed
*** empty log message ***
1 parent bf385c7 commit ce31076

File tree

1 file changed

+97
-13
lines changed

1 file changed

+97
-13
lines changed

doc/customizing.txt

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

5-
:Version: $Revision: 1.18 $
5+
:Version: $Revision: 1.19 $
6+
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
69

710
.. contents::
811

@@ -620,6 +623,7 @@ The basic processing of a web request proceeds as follows:
620623
4. render a template, resulting in HTML output
621624

622625
In some situations, exceptions occur:
626+
623627
- HTTP Redirect (generally raised by an action)
624628
- SendFile (generally raised by determine_context)
625629
here we serve up a FileClass "content" property
@@ -721,17 +725,20 @@ search
721725
Also handle the ":queryname" variable and save off the query to
722726
the user's query list.
723727

724-
Each of the actions is implemented by a corresponding *name*Action method on
728+
Each of the actions is implemented by a corresponding *actionAction* (where
729+
"action" is the name of the action) method on
725730
the roundup.cgi.Client class, which also happens to be in your instance as
726731
interfaces.Client. So if you need to define new actions, you may add them
727732
there (see `definining new web actions`_).
728733

729-
Each action also has a corresponding *name*Permission method which determines
734+
Each action also has a corresponding *actionPermission* (where
735+
"action" is the name of the action) method which determines
730736
whether the action is permissible given the current user. The base permission
731737
checks are:
732738

733739
login
734-
XXX TODO
740+
Determine whether the user has permission to log in.
741+
Base behaviour is to check the user has "Web Access".
735742
logout
736743
No permission checks are made.
737744
register
@@ -777,21 +784,95 @@ footer with your own code. This allows you to use a sidebar navigation scheme,
777784
for example.
778785

779786

780-
PageTemplates in a Nutshell
781-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
787+
How the templates work
788+
~~~~~~~~~~~~~~~~~~~~~~
782789

783-
PageTemplates consist of two core technologies:
790+
Roundup's templates consist of two core technologies:
784791

785792
TAL - Template Attribute Language
786793
This is the syntax which is woven into the HTML using the ``tal:`` tag
787794
attributes. A TAL parser pulls out the TAL commands from the attributes
788-
runs them using some expression engine. TAL gives:
795+
runs them using some expression engine. TAL gives us the following commands:
796+
797+
tal:define="variable expression; variable expression; ..."
798+
Define a new variable that is local to this tag and its contents. For
799+
example::
800+
801+
<html tal:define="title request/description">
802+
<head><title tal:content="title"></title></head>
803+
</html>
804+
805+
In the example, the variable "title" is defined as being the result of the
806+
expression "request/description". The tal:content command inside the <html>
807+
tag may then use the "title" variable.
808+
809+
tal:condition="expression"
810+
Only keep this tag and its contents if the expression is true. For example::
811+
812+
<p tal:condition="python:request.user.hasPermission('View', 'issue')">
813+
Display some issue information.
814+
</p>
815+
816+
In the example, the <p> tag and its contents are only displayed if the
817+
user has the View permission for issues. We consider the number zero, a
818+
blank string, an empty list, and the built-in variable nothing to be false
819+
values. Nearly every other value is true, including non-zero numbers, and
820+
strings with anything in them (even spaces!).
821+
822+
tal:repeat="variable expression"
823+
Repeat this tag and its contents for each element of the sequence that the
824+
expression returns, defining a new local variable and a special "repeat"
825+
variable for each element. For example::
826+
827+
<tr tal:repeat="u user/list">
828+
<td tal:content="u/id"></td>
829+
<td tal:content="u/username"></td>
830+
<td tal:content="u/realname"></td>
831+
</tr>
832+
833+
The example would iterate over the sequence of users returned by
834+
"user/list" and define the local variable "u" for each entry.
835+
836+
tal:replace="expression"
837+
Replace this tag with the result of the expression. For example::
838+
839+
<span tal:replace="request/user/realname"></span>
840+
841+
The example would replace the <span> tag and its contents with the user's
842+
realname. If the user's realname was "Bruce" then the resultant output
843+
would be "Bruce".
844+
845+
tal:content="expression"
846+
Replace the contents of this tag with the result of the expression. For
847+
example::
848+
849+
<span tal:content="request/user/realname">user's name appears here</span>
789850

790-
tal:define
791-
tal:replace
792-
tal:content
793-
tal:repeat
794-
tal:attributes
851+
The example would replace the contents of the <span> tag with the user's
852+
realname. If the user's realname was "Bruce" then the resultant output
853+
would be "<span>Bruce</span>".
854+
855+
tal:attributes="attribute expression; attribute expression; ..."
856+
Set attributes on this tag to the results of expressions. For example::
857+
858+
<a tal:attributes="href string:user${request/user/id}">My Details</a>
859+
860+
In the example, the "href" attribute of the <a> tag is set to the value of
861+
the "string:user${request/user/id}" expression, which will be something
862+
like "user123".
863+
864+
tal:omit-tag="expression"
865+
Remove this tag (but not its contents) if the expression is true. For
866+
example::
867+
868+
<span tal:omit-tag="python:1">Hello, world!</span>
869+
870+
would result in output of::
871+
872+
Hello, world!
873+
874+
Note that the commands on a given tag are evaulated in the order above, so
875+
*define* comes before *condition*, and so on.
795876

796877
Additionally, a tag is defined, tal:block, which is removed from output. Its
797878
content is not, but the tag itself is (so don't go using any tal:attributes
@@ -815,6 +896,9 @@ TALES - TAL Expression Syntax
815896
stringified. Path expressions may have an optional ``path:`` prefix, though
816897
they are the default expression type, so it's not necessary.
817898

899+
XXX | components of expressions
900+
XXX "nothing" and "default"
901+
818902
String Expressions - eg. ``string:hello ${user/name}``
819903
These expressions are simple string interpolations (though they can be just
820904
plain strings with no interpolation if you want. The expression in the

0 commit comments

Comments
 (0)