Skip to main content

Tahrir-API

API for interacting with the Tahrir database. Based on the Tahrir database model written by Ralph Bean. There are two classes that can be used in this module. The first is the TahrirDatabase class located in tahrir_api.dbapi and the second is the database model located in tahrir_api.model. The TahrirDatabase class is a high level way to interact with the database. The model is used for a slightly more low level way of interacting with the database. It allows for custom interactions with the database without having to use the TahrirDatabase class.

Development

System Requirements

Before getting started, ensure your system meets the following requirements:

Software Requirements

  • Python: 3.9 or higher

  • Poetry: Latest version for dependency management

  • Database: PostgreSQL 9.6+ (recommended) or SQLite (basic development)

  • Git: For version control

Operating System Requirement

  • Fedora Linux: Latest non-EOL versions

Note: Other distributions may work, but are not officially supported. The maintainers may not be able to assist with platform-specific issues on non-Fedora systems.

Project Setup

  1. Ensure that the necessary packages are installed:

$ sudo dnf install -y python3 python3-pip python3-devel poetry gcc krb5-devel git
  1. Clone your fork to the local storage and make it your current working directory:

$ git clone https://github.com/fedora-infra/tahrir-api.git
$ cd tahrir-api
  1. Create a virtual environment and activate it for installing project dependencies:

$ python3 -m venv venv
$ source venv/bin/activate
  1. Install project dependencies:

(venv) $ poetry check
(venv) $ poetry install

Database Setup

  1. Create a directory for storing the Tahrir database snapshot:

(venv) $ cd ..
(venv) $ mkdir badges-database
(venv) $ cd badges-database
  1. Download and extract the Tahrir database snapshot:

(venv) $ wget https://infrastructure.fedoraproject.org/infra/db-dumps/tahrir.dump.xz
(venv) $ unxz tahrir.dump.xz
  1. Create directories for persistent data and the database dump:

(venv) $ mkdir data dump
(venv) $ mv tahrir.dump dump/
  1. Pull the PostgreSQL container image:

(venv) $ podman pull docker.io/library/postgres:15
  1. Start the database container (be sure to rename the username and paths based on your development environment):

(venv) $ podman run \
    --name badges-database \
    --env POSTGRES_USER=badgesdb \
    --env POSTGRES_PASSWORD=badgesdb \
    --env POSTGRES_DB=badgesdb \
    --env PGDATA=/var/lib/postgresql/data/pgdata \
    --volume /home/username/Projects/badges-database/data:/var/lib/postgresql/data:Z \
    --volume /home/username/Projects/badges-database/dump:/badgesdb:Z \
    --publish 5432:5432 \
    --restart unless-stopped \
    --detach docker.io/library/postgres:15
  1. Once the database container has started, log in to the interactive shell using the password to begin importing the extracted dump:

(venv )$ podman pull docker.io/library/postgres:15
(venv )$ podman run \
  1. Execute the following SQL commands to create roles, load the database dump, and grant the needed access:

badgesdb=# create role "tahrir" with inherit nocreatedb nocreaterole noreplication nosuperuser valid until 'infinity' login password 'tahrir';
badgesdb=# create role "tahrir-readonly" with nocreatedb inherit nocreaterole noreplication nosuperuser valid until 'infinity' login password 'tahrir-readonly';
badgesdb=# \i badgesdb/tahrir.dump
badgesdb=# grant connect on database tahrir to "tahrir";
badgesdb=# grant all on all tables in schema public to "tahrir";
badgesdb=# grant all on all sequences in schema public to "tahrir";
badgesdb=# revoke create on schema public from public;
  1. Exit out of the interactive shell and log back in using the newly created credentials:

(venv )$ podman exec -ti badges-database psql --username badgesdb --password
  1. Verify the database setup:

(venv )$ tahrir=> \dt+

Run the tests

  1. Download and install tox:

(venv) $ cd ./tahrir-api
(venv) $ sudo dnf install tox
  1. Run the tests with tox:

(venv) $ tox

Download files

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

Source Distribution

tahrir_api-1.5.6.tar.gz (50.8 kB view details)

Uploaded Source

Built Distribution

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

tahrir_api-1.5.6-py3-none-any.whl (58.8 kB view details)

Uploaded Python 3

File details

Details for the file tahrir_api-1.5.6.tar.gz.

File metadata

  • Download URL: tahrir_api-1.5.6.tar.gz
  • Upload date:
  • Size: 50.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tahrir_api-1.5.6.tar.gz
Algorithm Hash digest
SHA256 be8ad34a15f598ab69634de804912c1800ba40f026a0e3704392aa76a0985c84
MD5 49fc6bbcf92ad62ed2280b406f62fee2
BLAKE2b-256 afc4415f1856a081c4e9546fa90930cebcfc3d8efbee32a091223773f044f141

See more details on using hashes here.

Provenance

The following attestation bundles were made for tahrir_api-1.5.6.tar.gz:

Publisher: main.yml on fedora-infra/tahrir-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tahrir_api-1.5.6-py3-none-any.whl.

File metadata

  • Download URL: tahrir_api-1.5.6-py3-none-any.whl
  • Upload date:
  • Size: 58.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tahrir_api-1.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fb98e4c92cbd7049b34390407f4bfa4ab24fc1154d95ef0fb768bdd1f58176a8
MD5 6041a85b0daa783d451c95e84b2ef909
BLAKE2b-256 1f2cbcc3e73926d31356cdc834a9340275afdd5edc0f92df0a5d1a9fba1b03ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for tahrir_api-1.5.6-py3-none-any.whl:

Publisher: main.yml on fedora-infra/tahrir-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.5.6 This release

2 files

1.5.5

2 files

1.5.4

2 files

1.5.3

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.5

2 files

1.1.4

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

0.8.1

1 file

0.8.0

1 file

0.7.2

2 files

0.7.0

1 file

0.6.1

1 file

0.6.0

1 file

0.5.1

1 file

0.5.0

1 file

0.4.2

1 file

0.4.1

1 file

0.4.0

1 file

0.3.0

1 file

0.2.8

1 file

0.2.7

1 file

0.2.6

1 file

0.2.5

1 file

0.2.4

1 file

0.2.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2.0

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.5

1 file

0.1.4

1 file

0.1.3.6

1 file

0.1.3.5

1 file

0.1.3.4

1 file

0.1.3.3

1 file

0.1.3.2

1 file

0.1.3.1

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

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