Mercurial > libervia-web
comparison src/server/pages.py @ 1065:5f97118dc82a
pages: fixed min_args for getPathArgs
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 14 Mar 2018 09:01:04 +0100 |
parents | c80649cdadd5 |
children | 8f77e36cd51d |
comparison
equal
deleted
inserted
replaced
1064:abc5d545dbaa | 1065:5f97118dc82a |
---|---|
560 | 560 |
561 Arguments will be put in request data. | 561 Arguments will be put in request data. |
562 Missing arguments will have None value | 562 Missing arguments will have None value |
563 @param names(list[unicode]): list of arguments to get | 563 @param names(list[unicode]): list of arguments to get |
564 @param min_args(int): if less than min_args are found, PageError is used with C.HTTP_BAD_REQUEST | 564 @param min_args(int): if less than min_args are found, PageError is used with C.HTTP_BAD_REQUEST |
565 use 0 to ignore | |
565 @param **kwargs: special value or optional callback to use for arguments | 566 @param **kwargs: special value or optional callback to use for arguments |
566 names of the arguments must correspond to those in names | 567 names of the arguments must correspond to those in names |
567 special values may be: | 568 special values may be: |
568 - '': use empty string instead of None when no value is specified | 569 - '': use empty string instead of None when no value is specified |
569 - '@': if value of argument is empty or '@', empty string will be used | 570 - '@': if value of argument is empty or '@', empty string will be used |
577 value = data[name[1:]] = [] | 578 value = data[name[1:]] = [] |
578 while True: | 579 while True: |
579 try: | 580 try: |
580 value.append(self.nextPath(request)) | 581 value.append(self.nextPath(request)) |
581 except IndexError: | 582 except IndexError: |
583 idx-=1 | |
582 break | 584 break |
583 else: | 585 else: |
584 idx+=1 | 586 idx+=1 |
585 else: | 587 else: |
586 try: | 588 try: |
587 value = data[name] = self.nextPath(request) | 589 value = data[name] = self.nextPath(request) |
588 except IndexError: | 590 except IndexError: |
589 data[name] = None | 591 data[name] = None |
590 break | 592 break |
591 | 593 |
592 if idx < min_args: | 594 if idx + 1 < min_args: |
593 log.warning(_(u"Missing arguments in URL (got {idx}, expected at least {min_args})").format( | 595 log.warning(_(u"Missing arguments in URL (got {idx}, expected at least {min_args})").format( |
594 idx = idx, min_args = min_args)) | 596 idx = idx, min_args = min_args)) |
595 self.pageError(request, C.HTTP_BAD_REQUEST) | 597 self.pageError(request, C.HTTP_BAD_REQUEST) |
596 | 598 |
597 for name in names[idx+1:]: | 599 for name in names[idx+1:]: |