Mercurial > p > roundup > code
comparison roundup/cgi/templating.py @ 6404:e29d5f4e0af4
issue2551132 - Setting form value in query string --- issues
Code now uses value in query string even if there is a default_value
set. Also handle the exception caused by an invalid value specified
in the query string.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Mon, 10 May 2021 16:47:51 -0400 |
| parents | 26e5c42f148c |
| children | 3dbf1bc5e567 |
comparison
equal
deleted
inserted
replaced
| 6403:9957d8d10783 | 6404:e29d5f4e0af4 |
|---|---|
| 731 | 731 |
| 732 # look up the correct HTMLProperty class | 732 # look up the correct HTMLProperty class |
| 733 for klass, htmlklass in propclasses: | 733 for klass, htmlklass in propclasses: |
| 734 if not isinstance(prop, klass): | 734 if not isinstance(prop, klass): |
| 735 continue | 735 continue |
| 736 value = prop.get_default_value() | |
| 737 return htmlklass(self._client, self._classname, None, prop, item, | 736 return htmlklass(self._client, self._classname, None, prop, item, |
| 738 value, self._anonymous) | 737 None, self._anonymous) |
| 739 | 738 |
| 740 # no good | 739 # no good |
| 741 raise KeyError(item) | 740 raise KeyError(item) |
| 742 | 741 |
| 743 def __getattr__(self, attr): | 742 def __getattr__(self, attr): |
| 1514 value = None | 1513 value = None |
| 1515 else: | 1514 else: |
| 1516 value = form.getfirst(self._formname).strip() or None | 1515 value = form.getfirst(self._formname).strip() or None |
| 1517 self._value = value | 1516 self._value = value |
| 1518 | 1517 |
| 1518 # if self._value is None see if we have a default value | |
| 1519 if self._value is None: | |
| 1520 self._value = prop.get_default_value() | |
| 1521 | |
| 1519 HTMLInputMixin.__init__(self) | 1522 HTMLInputMixin.__init__(self) |
| 1520 | 1523 |
| 1521 def __repr__(self): | 1524 def __repr__(self): |
| 1522 classname = self.__class__.__name__ | 1525 classname = self.__class__.__name__ |
| 1523 return '<%s(0x%x) %s %r %r>'%(classname, id(self), self._formname, | 1526 return '<%s(0x%x) %s %r %r>'%(classname, id(self), self._formname, |
| 2505 linkcl.get(optionid, propname) | 2508 linkcl.get(optionid, propname) |
| 2506 additional_fns.append(fn) | 2509 additional_fns.append(fn) |
| 2507 | 2510 |
| 2508 for optionid in options: | 2511 for optionid in options: |
| 2509 # get the option value, and if it's None use an empty string | 2512 # get the option value, and if it's None use an empty string |
| 2510 option = linkcl.get(optionid, k) or '' | 2513 try: |
| 2514 option = linkcl.get(optionid, k) or '' | |
| 2515 except IndexError: | |
| 2516 # optionid does not exist. E.G. | |
| 2517 # IndexError: no such queue z | |
| 2518 # can be set using ?queue=z in URL for | |
| 2519 # a new issue | |
| 2520 continue | |
| 2511 | 2521 |
| 2512 # figure if this option is selected | 2522 # figure if this option is selected |
| 2513 s = '' | 2523 s = '' |
| 2514 # record the marker for the selected item if requested | 2524 # record the marker for the selected item if requested |
| 2515 selected_mark='' | 2525 selected_mark='' |
