comparison doc/reference.txt @ 8262:2a7c3eeaf167

feat: add templating utils method dynamically; method to set http code Added new utils.set_http_response(integer) to set the HTML response code from a template. Useful for error handling inside template. Also noted that a real TemplatingUtils (like set_http_response) method gets the TemplatingUtils object instance, but there is no way to do this with registerUtil() from an extension file. Added new instance.registerUtilMethod() method to register a function in an extension as a method passing the client instance in as the first parameter (aka self).
author John Rouillard <rouilj@ieee.org>
date Tue, 07 Jan 2025 20:22:33 -0500
parents 7d72b9a9fe9c
children 78b13272d41b
comparison
equal deleted inserted replaced
8261:28c5030757d3 8262:2a7c3eeaf167
1145 mechanism. 1145 mechanism.
1146 1146
1147 * ``instance.registerUtil`` is used for adding `templating utilities`_ 1147 * ``instance.registerUtil`` is used for adding `templating utilities`_
1148 (see `adding a time log to your issues 1148 (see `adding a time log to your issues
1149 <customizing.html#adding-a-time-log-to-your-issues-4>`_ for an example) 1149 <customizing.html#adding-a-time-log-to-your-issues-4>`_ for an example)
1150
1151 * ``instance.registerUtilMethod`` is also used for adding `templating
1152 utilities`_, and provides a client instance by default to the
1153 function. This makes more complex templating actions easier to
1154 use. (see :ref:`dynamic_csp` for an example)
1150 1155
1151 * ``instance.registerAction`` is used to add more actions to the 1156 * ``instance.registerAction`` is used to add more actions to the
1152 instance and to web interface. See `Defining new web actions`_ 1157 instance and to web interface. See `Defining new web actions`_
1153 for details. Generic action can be added by inheriting from 1158 for details. Generic action can be added by inheriting from
1154 ``action.Action`` instead of ``cgi.action.Action``. 1159 ``action.Action`` instead of ``cgi.action.Action``.
3463 be added to the variable by using extensions_. 3468 be added to the variable by using extensions_.
3464 3469
3465 .. table:: 3470 .. table::
3466 :class: valign-top 3471 :class: valign-top
3467 3472
3468 =============== ======================================================== 3473 ================= ========================================================
3469 Method Description 3474 Method Description
3470 =============== ======================================================== 3475 ================= ========================================================
3471 Batch return a batch object using the supplied list 3476 Batch return a batch object using the supplied list
3472 anti_csrf_nonce returns the random nonce generated for this session 3477 anti_csrf_nonce returns the random nonce generated for this session
3473 expandfile load a file into a template and expand 3478 expandfile load a file into a template and expand
3474 '%(tokenname)s' in the file using 3479 '%(tokenname)s' in the file using
3475 values from the supplied dictionary. 3480 values from the supplied dictionary.
3476 html_quote quote some text as safe in HTML (ie. <, >, ...) 3481 html_quote quote some text as safe in HTML (ie. <, >, ...)
3477 html_calendar renders an HTML calendar used by the 3482 html_calendar renders an HTML calendar used by the
3478 ``_generic.calendar.html`` template (itself invoked by 3483 ``_generic.calendar.html`` template (itself invoked by
3479 the popupCalendar DateHTMLProperty method 3484 the popupCalendar DateHTMLProperty method
3480 readfile read JavaScript or other content in an external 3485 readfile read JavaScript or other content in an external
3481 file into the template. 3486 file into the template.
3482 url_quote quote some text as safe for a URL (ie. space, %, ...) 3487 set_http_response sets the HTTP response code for the request.
3483 =============== ======================================================== 3488 url_quote quote some text as safe for a URL (ie. space, %, ...)
3489 ================= ========================================================
3484 3490
3485 Additional info can be obtained by starting ``python`` with the 3491 Additional info can be obtained by starting ``python`` with the
3486 ``roundup`` subdirectory on your PYTHONPATH and using the Python help 3492 ``roundup`` subdirectory on your PYTHONPATH and using the Python help
3487 function like:: 3493 function like::
3488 3494

Roundup Issue Tracker: http://roundup-tracker.org/