Signals

Note

This feature is experimental.

Flatland can notify your code when events of interest occur during flatland processing. These signals can be used for advanced customization in your application or simply as a means for tracing and logging flatland activity during development.

Using Signals

To receive a signal, all you need is a function that can accept keyword arguments:

>>> def receiver(**kw):
...   print "Look what I got!", kw
...

Receiving functions are connected to one or more signals you’d like to receive:

>>> from flatland import signals
>>> signals.validator_validated.connect(receiver)

That’s it. Now each time flatland runs a validator, the receiver function will be called and passed some information about the validation that just occurred. There is no limit to the number of receivers connected to a signal.

Built-In Signals

validator_validated = <blinker.base.NamedSignal object at 0x3c058d0; 'validator_validated'>

Emitted after a validator has processed an element.

Parameters:
  • sender – the validator
  • element – the element being validated
  • state – the state passed to validate()
  • result – the result of validator execution

Contents

Topics