webutil
Common utilities and handler code for Python web apps.
Install with
pip install webutilSupports Python 3.9+
webutil is dedicated to the public domain. You may also use it under the CC0 public domain dedication.
Contents
flask_util: Flask decorators and handlers for caching, exception handling, regular expression URL routing, domain-wide redirects, rate limiting, headers, and serving XRD and JRD templates.
logs: Flask request handler that collects full trace logs from Google Cloud Logging, formats them nicely, and serves them
models: minor utility Model classes for the Google Cloud Datastore ndb library
testutil: misc utilities and helpers for unittest, requests, and urllib
util: wide variety of utilities for data structures, web code, etc.
webmention: Webmention endpoint discovery and sending
Changelog
2.0 - 2026-06-29
appengine_info:Add Cloud Run support.
flask_util:Add
block, abefore_requesthandler that blocks requests by client IP CIDR and/orUser-Agent.
models:Add new
WriteOnce,WriteOnceBlobPropertyndb property classes. (Moved here from arroba.)Add support for
$ENCRYPTED_PROPERTY_KEYenvironment variable.
testutil:Add new
@head_returns_200decorator.Drop
moxfromTestCase.Add new
unittest.mockandrequestshelpers toTestCase.
util:requests_*: add newlog_databoolean kwarg.
1.0 - 2026-05-27
Initial PyPI release. Moved out of oauth-dropins, where it’s been
maintained for the last 10+ years, into its own dedicated package,
pywebutil.
Release instructions
Here’s how to package, test, and ship a new release.
Pull from remote to make sure we’re at head.
sh git checkout main git pullRun the unit tests.
sh source local/bin/activate.csh gcloud emulators firestore start --host-port=:8089 --database-mode=datastore-mode < /dev/null >& /dev/null & python -m unittest discoverBump the version number in
pyproject.tomlanddocs/conf.py.git grepthe old version number to make sure it only appears in the changelog. Change the current changelog entry inREADME.mdfor this new version from unreleased to the current date.Build the docs. If you added any new modules, add them to the appropriate file(s) in
docs/source/. Then run./docs/build.sh.setenv ver X.Y git commit -am "release v$ver"
Upload to test.pypi.org for testing.
sh uv build twine upload -r pypitest dist/pywebutil-$ver.tar.gzInstall from test.pypi.org.
sh cd /tmp python -m venv local source local/bin/activate.csh pip install --upgrade pip pip install -i https://test.pypi.org/simple --extra-index-url https://pypi.org/simple pywebutilSmoke test that the code trivially loads and runs.
sh python # run test code belowTest code to paste into the interpreter:py from webutil import util util.__file__ util.UrlCanonicalizer()('http://asdf.com') # should print 'https://asdf.com/' exit()Tag the release in git. In the tag message editor, delete the generated comments at bottom, leave the first line blank (to omit the release “title” in github), put
### Notable changeson the second line, then copy and paste this version’s changelog contents below it.sh git tag -a v$ver --cleanup=verbatim git push git push --tagsClick here to draft a new release on GitHub. Enter
vX.Yin the Tag version box. Leave Release title empty. Copy### Notable changesand the changelog contents into the description text box.Upload to pypi.org!
sh twine upload dist/pywebutil-$ver.tar.gz