Package name: maslosoft_signals
The package is port of PHP package Maslosoft Signals to Python.
Instead of using custom, vintage annotations processor, the package uses standard Python decorators.
pip install maslosoft-signalsfrom maslosoft.signals import Signal, SignalFor, SlotFor
@SlotFor("my_app.signals.UserRegistered")
class SendWelcomeEmail:
def __init__(self, signal):
signal.sent = True
@SignalFor("my_app.slots.GatherSlot")
class GatherableModel:
pass
signals = Signal(paths=["src"])
signals.build()
# Emit a signal to all matching slots.
result = signals.emit(signal)
# Gather signal classes for a slot.
result = signals.gather(slot)The initial Python port supports:
SignalForon classesSlotForon classes for constructor injectionSlotForon methods for method injection- AST scanning of Python source files
- generation of
signals_definition.py - runtime loading through
Signal.build(),Signal.emit(), andSignal.gather()
This first slice does not port PHP-style property injection.