django-status-signal
enhanced django signal which enable you to trigger a signal only if the model instance is in a certain status
Install
pip3 install django-status-signal
Usage
In many scenarios, you may want to trigger a function only when a model's status has been changed to a certain status. But the default django's signal can only use the sender(an model instance) to search the receivers. Here comes the solution.
from django_status_signal import Signal
class Task(models.Model):
status = models.CharField(
choices=(
("start", "start"),
("doing", "doing"),
("success", "success"),
("fail", "fail"),
),
max_length=31,
)
# create a signal and connect it to different status
mysignal = Singal()
mysignal.connect(send_message, Task, dispatch_status="fail")
mysignal.connect(reward, Task, dispatch_status="success")
# call the signal
task = Task.objects.create('start')
mysignal.send(Task, instance=task, task.status) # nothing will happen
task.status = 'success'
task.save()
mysignal.send(Task, instance=task, task.status) # the send_message will be called
TODO
when this project is stable enough, I want to merge the code into django project, so all the post_save, post_delete can accept dispatch_status parameter.
LICENSE
there are many code copied from the django project, so the LICENSE should stay the same as django's LICENSE.
Metadata
Release files for django-status-signal 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-status-signal-0.0.2.tar.gz | 4.7 kB | Without provenance | Details for django-status-signal-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_status_signal-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for django_status_signal-0.0.2-py3-none-any.whl |
Total release size: 11.4 kB
Release files / django-status-signal-0.0.2.tar.gz
| Download URL | django-status-signal-0.0.2.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7af2748c9d2b83179d62e731a295723068d3db4edd23eb05e63e2bde3caee4eb
|
|
BLAKE2b-256 checksum How to use checksums |
81cd1aa01d0cfb06fcd0c64e76f70a84880ab3546f7f0be0586385f48ab67e11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10
|
Release files / django_status_signal-0.0.2-py3-none-any.whl
| Download URL | django_status_signal-0.0.2-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
363f3d5e3e6f3b6fc7685bad5ce7303147a1dc3c2ed5c59acbebeb1dfd8db65a
|
|
BLAKE2b-256 checksum How to use checksums |
3ad1a11cc0cf5f25d6de5e111ea7c43409682d793729713cd6d1885f72aab01f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10
|
Security for django-status-signal 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.