scenario.handlers module

Handler management.

HANDLERS

Main instance of Handlers.

class Handler

Bases: object

Handler storage.

__init__(event, handler, scenario_definition, once)
Parameters:
  • event – Event triggered.

  • handler – Handler function.

  • scenario_definition – Related scenario, if any.

  • onceOnce flag.

event

Event triggered.

handler

Handler function.

scenario_definition

Related scenario, if any.

once

Once flag.

class Handlers

Bases: Logger

Handler manager.

__init__()

Initializes an empty handler list.

_handlers

Installed handlers.

Dictionary that associates events with their related handler list.

install(event, handler, scenario=None, once=False, first=False)

Installs a handler.

Parameters:
  • event – Event triggered.

  • handler – Handler function.

  • scenario – Related scenario definition, if any.

  • onceOnce flag.

  • first

    True to install this handler at the head of the list attached with the event given.

    Warning

    Does not prevent a later handler to be installed before this one.

uninstall(event, handler)

Removes the handler.

Parameters:
  • event – Event triggered.

  • handler – Handler function.

callhandlers(event, data)

Calls applicable handlers for the given event.

Parameters:
  • event – Event met.

  • data – Event data to pass on when calling each handler.