gwk / pithy

Python 3.7+ utility library.
Other
5 stars 1 forks source link

Factor out paging control #12

Closed gwk closed 1 year ago

gwk commented 1 year ago

I have created pithy/html/parts.py, which has an unimplemented function pagination_control. The implementation should be factored out from pithy.select render_pagination_control. The tricky part is that I do not want to use the QueryParams type. Instead we should treat the params argument as a generic Mapping. You should iterate over the items in the mapping, swapping in the new offset.

Something like:

from url lib.parse import urlencode

page_params = dict(params)
page_params['offset'] = offset
href = f'?{urlencode(tuple((k, str(v)) for k, v in params.items()))}'

That last line was copied from pithy.url.fmt_url, which might serve as a reference to play with if something doesn't seem right.

davlis-tr commented 1 year ago

PR https://github.com/gwk/pithy/pull/13

gwk commented 1 year ago

Merged in 6f7bd25.