Stop trying to make fetch happen.
Project description
beckon
Stop trying to make fetch happen.
A typed component registry backed by zope.interface. Register
components behind formal interfaces. Look them up without circular
imports. Relationships are inferred and bidirectional.
Install
pip install beckon
For Django integration:
pip install beckon[django]
Quick Start
from zope.interface import Interface
from beckon import register, BeckonInterface
class _IService(Interface):
pass
IService = BeckonInterface(_IService)
# register
register(IService, MyService, name='email')
# beckon
import beckon
beckon(IService, 'email') # -> MyService
beckon(IService) # -> [('email', MyService)]
The module itself is callable — import beckon; beckon(...) works
without importing the function separately.
Django Integration
Add beckon.django to INSTALLED_APPS:
INSTALLED_APPS = [
'beckon.django',
# ...
]
This registers a name resolver for Django models (_meta.label_lower)
and provides IModel:
from beckon import register
from beckon.django import IModel
from .models import Post
register(IModel, Post)
import beckon
from beckon.django import IModel
Post = beckon(IModel, 'posts.post')
Custom Interfaces with Relationships
from zope.interface import Interface
from beckon import BeckonInterface, register
class _ISerializer(Interface):
pass
ISerializer = BeckonInterface(_ISerializer, infer_from='model')
Register a serializer and it automatically links to its model:
register(IModel, Post)
register(ISerializer, PostSerializer) # infers from Meta.model
beckon(ISerializer, 'posts.post') # -> PostSerializer
beckon(IModel, 'posts.post') # -> Post (reverse works too)
Type Safety
Interfaces carry generic type information:
IModel: BeckonInterface[type[Model]] = BeckonInterface(_IModel)
mypy infers return types automatically:
beckon(IModel, 'auth.user') # mypy sees: type[Model] | None
Define your own typed interfaces and get the same inference:
IPermission: BeckonInterface[type[BasePermission]] = BeckonInterface(_IPermission)
beckon(IPermission, 'is_admin') # mypy sees: type[BasePermission] | None
License
BSD 2-Clause. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 beckon-0.1.0.tar.gz.
File metadata
- Download URL: beckon-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85fe444ad883cee33d204b197315e0a4414ada1cf7f6f4d88725325c0dfe2ca8
|
|
| MD5 |
53a68cd700895e399f7147663fae5ca8
|
|
| BLAKE2b-256 |
36095174ab42e14f39f98c47017d6a49547f5066c0262dfbc5024e54f1208aee
|
Provenance
The following attestation bundles were made for beckon-0.1.0.tar.gz:
Publisher:
publish.yml on LimpidTech/beckon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beckon-0.1.0.tar.gz -
Subject digest:
85fe444ad883cee33d204b197315e0a4414ada1cf7f6f4d88725325c0dfe2ca8 - Sigstore transparency entry: 1077563996
- Sigstore integration time:
-
Permalink:
LimpidTech/beckon@760313c4229a7d5f955b87af4aedbb7d35d934b0 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/LimpidTech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@760313c4229a7d5f955b87af4aedbb7d35d934b0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file beckon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: beckon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 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 |
36d003b79433c89ddb9e516178282643b593f45b244fcc4ed20b296f83cf188e
|
|
| MD5 |
ce088f0c7305158150a6652e56eccb90
|
|
| BLAKE2b-256 |
d3b0ac3370205798615c4ed203a23eee321ef60b91f08c3fe80bfd5dc2198c33
|
Provenance
The following attestation bundles were made for beckon-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on LimpidTech/beckon
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
beckon-0.1.0-py3-none-any.whl -
Subject digest:
36d003b79433c89ddb9e516178282643b593f45b244fcc4ed20b296f83cf188e - Sigstore transparency entry: 1077564003
- Sigstore integration time:
-
Permalink:
LimpidTech/beckon@760313c4229a7d5f955b87af4aedbb7d35d934b0 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/LimpidTech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@760313c4229a7d5f955b87af4aedbb7d35d934b0 -
Trigger Event:
push
-
Statement type: