The Swiss Army knife to customize Indico
Project description
Indico Patcher
The Swiss Army knife for Indico plugin development.
Indico plugin development primarily relies on flask-pluginengine, Jinja template hooks or core signals to extend and modify system functionality. This, however, falls short in many other cases. Indico Patcher offers a clean interface to patch Indico code at runtime, allowing for things such as:
- Adding or overriding properties and intercepting methods in classes
- Reordering, modifying and removing fields in WTForms forms
- Adding new columns and relationships to SQLAlchemy models
- Adding new members to Enums
For more examples and usage information, please refer to the patching guide. For general information about Indico plugin development, please refer to the official guide. Not yet supported cases are tracked in TODO.md.
Installation
Indico Patcher is available on PyPI as indico-patcher and can be installed with pip:
pip install indico-patcher
Usage
Indico Patcher is a library designed to be used by Indico plugins. It provides a patch function that can be used as a decorator to patch Indico classes and enums.
from indico_patcher import patch
The @patch decorator will inject the members defined in the decorated class into a given class or enum. Check below for some examples.
Examples
Adding a new column and a relationship to an already existing SQLAlchemy model:
@patch(User)
class _User:
credit_card_id = db.Column(db.String, ForeignKey('credit_cards.id'))
credit_card = db.relationship('CreditCard', backref=backref('user'))
Adding a new field to an already existing WTForms form:
@patch(UserPreferencesForm)
class _UserPreferencesForm:
credit_card = StringField('Credit Card')
def validate_credit_card(self, field):
...
Adding a new member to an already defined Enum:
@patch(UserTitle, padding=100)
class _UserTitle(RichIntEnum):
__titles__ = [None, 'Madam', 'Sir', 'Rev.']
madam = 1
sir = 2
rev = 3
For more examples and usage information, please refer to the patching guide.
Caveats
[!WARNING] With great power comes great responsibility.
Runtime patching is a powerful and flexible strategy but it will lead to code that may break without notice as the Indico project evolves. Indico Patcher makes patching Indico dangerously easy so keep in mind a few things when using it.
- Think of Indico Patcher as a last resort tool that abuses Indico internal API. Indico developers may change or completely remove the classes and enums that you are patching at any time.
- If you can achieve the same result with a signal or a template hook, you should probably do that instead. These are considered stable APIs that Indico developers will try to keep backwards compatible or communicate breaking changes.
- If the signal or hook that you need doesn't exist, consider contributing it to Indico via pull request or asking for it in the Indico forum or the official #indico channel.
Development
For developing indico-patcher you will need to have the following tools installed and available in your path:
git(available in most systems)make(available in most systems)uv(installation guide)
Clone the repository locally:
git clone https://github.com/unconventionaldotdev/indico-patcher
cd indico-patcher
Make sure to have the right versions of python:
uv python install # reads from .python-version
Install the project with its dependencies:
make install
Contributing
Run linters locally before pushing:
uv run make lint
Run tests with:
uv run make test
Tests can be run against all supported Python versions with:
uv run tox
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file indico_patcher-0.3.2-py3-none-any.whl.
File metadata
- Download URL: indico_patcher-0.3.2-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa1286dd8c2314a798794a730065c6466410a9feb51c69b8a912cfaa294b4948
|
|
| MD5 |
6b314bdb3dc14f18a9cd4b62450bddfa
|
|
| BLAKE2b-256 |
1f09bc836e1f98d3da0b6fe877923b60e4e37071fb54f94f374b3e7055ab406e
|
Provenance
The following attestation bundles were made for indico_patcher-0.3.2-py3-none-any.whl:
Publisher:
releasing.yaml on unconventionaldotdev/indico-patcher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
indico_patcher-0.3.2-py3-none-any.whl -
Subject digest:
aa1286dd8c2314a798794a730065c6466410a9feb51c69b8a912cfaa294b4948 - Sigstore transparency entry: 969500182
- Sigstore integration time:
-
Permalink:
unconventionaldotdev/indico-patcher@608fea3d202bbbdb040f348e66618eb0f97feadd -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/unconventionaldotdev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
releasing.yaml@608fea3d202bbbdb040f348e66618eb0f97feadd -
Trigger Event:
push
-
Statement type: