22Customising 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
591591the access through its main() method. This means that you can do pretty much
592592anything you want as a web interface to your instance.
593593
594+ Figuring out what is displayed
595+ ::::::::::::::::::::::::::::::
596+
594597Most customisation of the web view can be done by modifying the templates in
595598the instance **html** directory. There are several types of files in there:
596599
@@ -615,6 +618,9 @@ user.register
615618style.css
616619 a static file that is served up as-is
617620
621+ How requests are processed
622+ ::::::::::::::::::::::::::
623+
618624The basic processing of a web request proceeds as follows:
619625
6206261. 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+
639648To determine the "context" of a request, we look at the URL and the special
640649request variable ``:template``. The URL path after the instance identifier
641650is 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
685700login
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+
9131005Displaying Properties
9141006~~~~~~~~~~~~~~~~~~~~~
9151007
@@ -931,11 +1023,11 @@ An index view specifier (URL fragment) looks like this (whitespace has been
9311023added 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
9401032The index view is determined by two parts of the specifier: the layout part and
9411033the 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
9581050the "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-
9651053Filtering of indexes
9661054::::::::::::::::::::
9671055
0 commit comments