22Customising Roundup
33===================
44
5- :Version: $Revision: 1.28 $
5+ :Version: $Revision: 1.29 $
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
@@ -778,9 +778,8 @@ The following variables are available to templates.
778778.. taken from roundup.cgi.templating.RoundupPageTemplate docstring
779779
780780*context*
781- The current context. This is either None, a wrapper around a
782- hyperdb class (an HTMLClass) or a wrapper around a hyperdb item (an
783- HTMLItem).
781+ The current context. This is either None, a
782+ `hyperdb class wrapper`_ or a `hyperdb item wrapper`_
784783*request*
785784 Includes information about the current request, including:
786785 - the url
@@ -818,15 +817,20 @@ The following variables are available to templates.
818817
819818 <span>Hello, World!</span>
820819
820+ *utils*
821+ This variable makes available some utility functions like batching.
822+
821823The context variable
822824~~~~~~~~~~~~~~~~~~~~
823825
824826The *context* variable is one of three things based on the current context
825827(see `determining web context`_ for how we figure this out):
826828
8278291. if we're looking at a "home" page, then it's None
828- 2. if we're looking at a specific hyperdb class, it's an HTMLClass instance
829- 3. if we're looking at a specific hyperdb item, it's an HTMLItem instance
830+ 2. if we're looking at a specific hyperdb class, it's a
831+ `hyperdb class wrapper`_.
832+ 3. if we're looking at a specific hyperdb item, it's a
833+ `hyperdb item wrapper`_.
830834
831835If the context is not None, we can access the properties of the class or item.
832836The only real difference between cases 2 and 3 above are:
@@ -838,10 +842,128 @@ The only real difference between cases 2 and 3 above are:
838842 a real, or true value in the third. Thus we can determine whether we're
839843 looking at a real item from the hyperdb by testing "context/id".
840844
845+ Hyperdb class wrapper
846+ :::::::::::::::::::::
847+
848+ Note: this is implemented by the roundup.cgi.templating.HTMLClass class.
849+
850+ This wrapper object provides access to a hyperb class. It is used primarily
851+ in both index view and new item views, but it's also usable anywhere else that
852+ you wish to access information about a class, or the items of a class, when
853+ you don't have a specific item of that class in mind.
854+
855+ We allow access to properties. There will be no "id" property. The value
856+ accessed through the property will be the current value of the same name from
857+ the CGI form.
858+
859+ There are several methods available on these wrapper objects:
860+
861+ =========== =============================================================
862+ Method Description
863+ =========== =============================================================
864+ properties return a `hyperdb property wrapper`_ for all of this class'
865+ properties.
866+ list lists all of the active (not retired) items in the class.
867+ csv return the items of this class as a chunk of CSV text.
868+ propnames lists the names of the properties of this class.
869+ filter lists of items from this class, filtered and sorted
870+ by the current *request* filterspec/filter/sort/group args
871+ classhelp display a link to a javascript popup containing this class'
872+ "help" template.
873+ submit generate a submit button (and action hidden element)
874+ renderWith render this class with the given template.
875+ history returns 'New node - no history' :)
876+ =========== =============================================================
877+
878+ Note that if you have a property of the same name as one of the above methods,
879+ you'll need to access it using a python "item access" expression. For example::
880+
881+ python:context['list']
882+
883+ will access the "list" property, rather than the list method.
884+
885+
886+ Hyperdb item wrapper
887+ ::::::::::::::::::::
888+
889+ Note: this is implemented by the roundup.cgi.templating.HTMLItem class.
890+
891+ This wrapper object provides access to a hyperb item.
892+
893+ We allow access to properties. There will be no "id" property. The value
894+ accessed through the property will be the current value of the same name from
895+ the CGI form.
896+
897+ There are several methods available on these wrapper objects:
898+
899+ =============== =============================================================
900+ Method Description
901+ =============== =============================================================
902+ submit generate a submit button (and action hidden element)
903+ journal return the journal of the current item (**not implemented**)
904+ history render the journal of the current item as HTML
905+ renderQueryForm specific to the "query" class - render the search form for
906+ the query
907+ hasPermission specific to the "user" class - determine whether the user
908+ has a Permission
909+ =============== =============================================================
910+
911+
912+ Note that if you have a property of the same name as one of the above methods,
913+ you'll need to access it using a python "item access" expression. For example::
914+
915+ python:context['journal']
916+
917+ will access the "journal" property, rather than the journal method.
918+
919+
920+ Hyperdb property wrapper
921+ ::::::::::::::::::::::::
922+
923+ Note: this is implemented by subclasses roundup.cgi.templating.HTMLProperty
924+ class (HTMLStringProperty, HTMLNumberProperty, and so on).
925+
926+ This wrapper object provides access to a single property of a class. Its
927+ value may be either:
928+
929+ 1. if accessed through a `hyperdb item wrapper`_, then it's a value from the
930+ hyperdb
931+ 2. if access through a `hyperdb class wrapper`_, then it's a value from the
932+ CGI form
933+
934+
935+ The property wrapper has some useful attributes:
936+
937+ =============== =============================================================
938+ Attribute Description
939+ =============== =============================================================
940+ _name the name of the property
941+ _value the value of the property if any
942+ =============== =============================================================
943+
944+ There are several methods available on these wrapper objects:
945+
946+ =========== =============================================================
947+ Method Description
948+ =========== =============================================================
949+ plain render a "plain" representation of the property
950+ field render a form edit field for the property
951+ stext specific to String properties - render the value of the
952+ property as StructuredText (requires the StructureText module
953+ to be installed separately)
954+ multiline specific to String properties - render a multiline form edit
955+ field for the property
956+ email specific to String properties - render the value of the
957+ property as an obscured email address
958+ =========== =============================================================
959+
960+ XXX do the other properties
841961
842962The request variable
843963~~~~~~~~~~~~~~~~~~~~
844964
965+ Note: this is implemented by the roundup.cgi.templating.HTMLRequest class.
966+
845967The request variable is packed with information about the current request.
846968
847969.. taken from roundup.cgi.templating.HTMLRequest docstring
@@ -874,6 +996,19 @@ filterspec values to filter the index on
874996search_text text to perform a full-text search on for an index
875997=========== ================================================================
876998
999+ The db variable
1000+ ~~~~~~~~~~~~~~~
1001+
1002+ Note: this is implemented by the roundup.cgi.templating.HTMLDatabase class.
1003+
1004+ Allows access to all hyperdb classes as attributes of this variable. If you
1005+ want access to the "user" class, for example, you would use::
1006+
1007+ db/user
1008+ python:db.user
1009+
1010+ The access results in a `hyperdb class wrapper`_.
1011+
8771012
8781013Displaying Properties
8791014---------------------
0 commit comments