webutil

Common utilities and handler code for Python web apps.

  • Install with pip install webutil

  • Supports Python 3.9+

  • Documentation

webutil is dedicated to the public domain. You may also use it under the CC0 public domain dedication.

Contents

Changelog

2.0 - 2026-06-29

  • appengine_info:

  • flask_util:

    • Add block, a before_request handler that blocks requests by client IP CIDR and/or User-Agent.

  • models:

    • Add new WriteOnce, WriteOnceBlobProperty ndb property classes. (Moved here from arroba.)

    • Add support for $ENCRYPTED_PROPERTY_KEY environment variable.

  • testutil:

    • Add new @head_returns_200 decorator.

    • Drop mox from TestCase.

    • Add new unittest.mock and requests helpers to TestCase.

  • util:

    • requests_*: add new log_data boolean 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.

  1. Pull from remote to make sure we’re at head. sh  git checkout main  git pull

  2. Run 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 discover

  3. Bump the version number in pyproject.toml and docs/conf.py. git grep the old version number to make sure it only appears in the changelog. Change the current changelog entry in README.md for this new version from unreleased to the current date.

  4. Build the docs. If you added any new modules, add them to the appropriate file(s) in docs/source/. Then run ./docs/build.sh.

  5. setenv ver X.Y
    git commit -am "release v$ver"
    
  6. Upload to test.pypi.org for testing. sh  uv build  twine upload -r pypitest dist/pywebutil-$ver.tar.gz

  7. Install 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 pywebutil

  8. Smoke test that the code trivially loads and runs. sh  python  # run test code below Test code to paste into the interpreter: py  from webutil import util  util.__file__  util.UrlCanonicalizer()('http://asdf.com')  # should print 'https://asdf.com/'  exit()

  9. 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 changes on 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 --tags

  10. Click here to draft a new release on GitHub. Enter vX.Y in the Tag version box. Leave Release title empty. Copy ### Notable changes and the changelog contents into the description text box.

  11. Upload to pypi.org! sh  twine upload dist/pywebutil-$ver.tar.gz