Skip to content

Maslosoft/PySignals

Repository files navigation

Package name: maslosoft_signals

Introduction

The package is port of PHP package Maslosoft Signals to Python.

Instead of using custom, vintage annotations processor, the package uses standard Python decorators.

Installation

pip install maslosoft-signals

Usage

from 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)

Current scope

The initial Python port supports:

  • SignalFor on classes
  • SlotFor on classes for constructor injection
  • SlotFor on methods for method injection
  • AST scanning of Python source files
  • generation of signals_definition.py
  • runtime loading through Signal.build(), Signal.emit(), and Signal.gather()

This first slice does not port PHP-style property injection.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors