Mercurial > p > roundup > code
diff doc/upgrading.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 | 6bd11a73f2ed |
| children | 35beff316883 |
line wrap: on
line diff
--- a/doc/upgrading.txt Sun Jan 05 00:59:12 2025 -0500 +++ b/doc/upgrading.txt Tue Jan 07 20:22:33 2025 -0500 @@ -253,6 +253,28 @@ to the data format (mime type, API version) will return 406 errors, where some previously resulted in 400 errors. +New method for registering templating utils (info) +-------------------------------------------------- + +If you are building a template utility function that needs access +to: + + * the database + * the client instance + * the form the user submitted + +you had to pass these objects from the template using the ``db``, +``request.client`` or ``request.form`` arguments. + +A new method for registering a template utility has been +added. If you use the ``instance`` object's +``registerUtilMethod()`` to register a utility function, you do +not need to pass these arguments. The function is called as a +method and the first argument is a ``client`` instance from which +the database (client.db), form (client.form). + +You can find an example in :ref:`dynamic_csp`. + .. index:: Upgrading; 2.3.0 to 2.4.0 Migrating from 2.3.0 to 2.4.0
