Skip to main content

Utilities for DBCA Django apps

Project description

Overview

DBCA Django utility classes and functions.

Requirements

  • Python 3.10 or later
  • Django 4.2 or later

Development

Dependencies for this project are managed using uv. With uv installed, change into the project directory and run:

uv sync

Activate the virtualenv like so:

source .venv/bin/activate

Run unit tests using pytest (or tox, to test against multiple Python versions):

pytest -sv
tox -v

Releases

Tagged releases are built and pushed to PyPI automatically using a GitHub workflow in the project. Update the project version in pyproject.toml and tag the required commit with the same value to trigger a release. Packages can also be built and uploaded manually to PyPI using uv, if required:

uv build
uv publish

Installation

  1. Install via uv/pip/etc.: pip install dbca-utils

SSO Login Middleware

This will automatically login and create users using headers from an upstream proxy (REMOTE_USER and some others). The logout view will redirect to a separate logout page which clears the SSO session.

Usage

Add dbca_utils.middleware.SSOLoginMiddleware to settings.MIDDLEWARE (after both of django.contrib.sessions.middleware.SessionMiddleware and django.contrib.auth.middleware.AuthenticationMiddleware. Ensure that AUTHENTICATION_BACKENDS contains django.contrib.auth.backends.ModelBackend, as this middleware depends on it for retrieving the logged in user for a session. Note that the middleware will still work without it, but will reauthenticate the session on every request, and request.user.is_authenticated won't work properly/will be false.

Example:

MIDDLEWARE = [
    ...,
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'dbca_utils.middleware.SSOLoginMiddleware'
    ...,
]

Audit model mixin

AuditMixin is an extension of Django.db.model.Model that adds a number of additional fields:

  • creator - FK to AUTH_USER_MODEL, used to record the object creator
  • modifier - FK to AUTH_USER_MODEL, used to record who the object was last modified by
  • created - a timestamp that is set on initial object save
  • modified - an auto-updating timestamp (on each object save)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbca_utils-2.1.5.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbca_utils-2.1.5-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file dbca_utils-2.1.5.tar.gz.

File metadata

  • Download URL: dbca_utils-2.1.5.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for dbca_utils-2.1.5.tar.gz
Algorithm Hash digest
SHA256 858451660d5ac1363db9ff32ab2ad4f227e36b1d438822d4a75368bfacab3fd1
MD5 58b2b31768426f53ed751a5b036bb595
BLAKE2b-256 8beac3a270b9dfdc18e7bc10e00e850403ac395579101832844a19f93b33ada0

See more details on using hashes here.

File details

Details for the file dbca_utils-2.1.5-py3-none-any.whl.

File metadata

  • Download URL: dbca_utils-2.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.7

File hashes

Hashes for dbca_utils-2.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 aaf193310200d1e66853faa872088ff65552f430ae2007e537d53284fad113f8
MD5 32ebc97d39747e2f255c0812113aa983
BLAKE2b-256 71cf895e2242df749ed53723aa79489a149069e06a8fa19c8ae04e83a0b8c084

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page