Simple function for URL generation. Position arguments are used for the URL path and keyword arguments are used for the url parameters.
(*args, **kw)
| 52 | |
| 53 | |
| 54 | def href(*args, **kw): |
| 55 | """ |
| 56 | Simple function for URL generation. Position arguments are used for the |
| 57 | URL path and keyword arguments are used for the url parameters. |
| 58 | """ |
| 59 | result = [f"{request.script_root if request else ''}/"] |
| 60 | for idx, arg in enumerate(args): |
| 61 | result.append(f"{'/' if idx else ''}{quote(arg)}") |
| 62 | if kw: |
| 63 | result.append(f"?{urlencode(kw)}") |
| 64 | return "".join(result) |
| 65 | |
| 66 | |
| 67 | def format_datetime(obj): |