changeset 1284:65c43eec15ad

pages: `on_data_post` can be set to the string `continue` instead of a callable: if `on_data_post` == "continue", then request won't be stopped if `POST` method is used, and `render` method can be used to handle it.
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 16:47:51 +0200
parents 436ef2ad92af
children 37a582b0fe53
files libervia/server/pages.py
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libervia/server/pages.py	Fri Jun 19 16:47:51 2020 +0200
+++ b/libervia/server/pages.py	Fri Jun 19 16:47:51 2020 +0200
@@ -160,7 +160,9 @@
             This method is mutually exclusive with render
         @param on_data_post(callable, None): method to call when data is posted
             None if data post is not handled
-            on_data_post can return a string with following value:
+            "continue" if data post is not handled there, and we must not interrupt
+            workflow (i.e. it's handled in "render" method).
+            otherwise, on_data_post can return a string with following value:
                 - C.POST_NO_CONFIRM: confirm flag will not be set
             on_data_post can raise following exceptions:
                 - exceptions.DataError: value is incorrect, message will be displayed
@@ -1680,8 +1682,6 @@
                             .format(theme=theme, vhost=self.vhost_root)))
                     else:
                         session_data.theme = theme
-
-
         try:
 
             try:
@@ -1713,7 +1713,9 @@
                     self.pageError(request, C.HTTP_BAD_REQUEST)
 
                 if request.method == C.HTTP_METHOD_POST:
-                    if self.on_data_post is None:
+                    if self.on_data_post == 'continue':
+                        pass
+                    elif self.on_data_post is None:
                         # if we don't have on_data_post, the page was not expecting POST
                         # so we return an error
                         self.pageError(request, C.HTTP_BAD_REQUEST)