web.input can give back either a string or list depending on the field's default. The availability params come in as scalar strings, but we defensively unwrap lists too so a future change to the input declaration doesn't silently break this comparison.
(param: dict, key: str)
| 139 | |
| 140 | |
| 141 | def _param_first(param: dict, key: str) -> str: |
| 142 | """web.input can give back either a string or list depending on the field's |
| 143 | default. The availability params come in as scalar strings, but we |
| 144 | defensively unwrap lists too so a future change to the input declaration |
| 145 | doesn't silently break this comparison.""" |
| 146 | val = param.get(key) |
| 147 | if isinstance(val, list): |
| 148 | return val[0] if val else "" |
| 149 | return "" if val is None else str(val) |
| 150 | |
| 151 | |
| 152 | @public |