gavo.base.observer module

Observers are objects listening to EventDispatchers.

They are mostly used as bases for UIs in the context of the DC.

class gavo.base.observer.ObserverBase(dispatcher: EventDispatcher)[source]

Bases: object

a base class for observers.

Observers have methods listening to certain events. Use the listen decorator above to make the connections. The actual event subscriptions are done in the constructor.

The signature of the listeners always is:

listener(dispatcher, arg) -> ignored

dispatcher is the EventDispatcher instance propagating the event. It has lots of useful attributes explained in base.event’s notifyXXX docstrings.

You can listen to anything that has a notify method in the EventDispatcher.

Observers are used in DaCHS for both logging and notification of users. Code generally does not use them directly but instead calls base.ui.notifyXXX; where you don’t have base, try the slower utils.misctricks.sendUIEvent.

gavo.base.observer.listensTo(*args: str) Callable[source]

a decorator to make a method listen to a set of events.

It receives one or more event names.