changeset 1065:5f97118dc82a

pages: fixed min_args for getPathArgs
author Goffi <goffi@goffi.org>
date Wed, 14 Mar 2018 09:01:04 +0100
parents abc5d545dbaa
children d1324e43d448
files src/server/pages.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/server/pages.py	Sun Mar 11 19:33:38 2018 +0100
+++ b/src/server/pages.py	Wed Mar 14 09:01:04 2018 +0100
@@ -562,6 +562,7 @@
         Missing arguments will have None value
         @param names(list[unicode]): list of arguments to get
         @param min_args(int): if less than min_args are found, PageError is used with C.HTTP_BAD_REQUEST
+            use 0 to ignore
         @param **kwargs: special value or optional callback to use for arguments
             names of the arguments must correspond to those in names
             special values may be:
@@ -579,6 +580,7 @@
                     try:
                         value.append(self.nextPath(request))
                     except IndexError:
+                        idx-=1
                         break
                     else:
                         idx+=1
@@ -589,7 +591,7 @@
                     data[name] = None
                     break
 
-        if idx < min_args:
+        if idx + 1 < min_args:
             log.warning(_(u"Missing arguments in URL (got {idx}, expected at least {min_args})").format(
                 idx = idx, min_args = min_args))
             self.pageError(request, C.HTTP_BAD_REQUEST)