Package gavo :: Package base :: Module events :: Class EventDispatcher
[frames] | no frames]

Class EventDispatcher

source code

object --+
         |
        EventDispatcher

is the central event dispatcher.

Events are posted by using notify* methods. Various handlers can then attach to them.

Nested Classes
  __metaclass__
is a metaclass for dispatching of messages.
Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
suspended(*args, **kwds)
a context manager suspending notification for a specific event.
source code
 
subscribe(self, evName, callback) source code
 
unsubscribe(self, evName, callback)
removes a callback from evName's callback list.
source code
 
notifyExceptionMutation(self, *args, **kwargs)
is called when an exception is being handled by raising newExc.
source code
 
logOldExc(self, newExc)
notifies of and ExceptionMutation and returns newExc.
source code
 
notifyNewSource(self, *args, **kwargs)
is called when a new source is being operated on.
source code
 
notifySourceError(self, *args, **kwargs)
is called when a parse error occurred in a source.
source code
 
notifySourceFinished(self, *args, **kwargs)
is called when a source file has been processed.
source code
 
notifyShipout(self, *args, **kwargs)
is called when certain table implementations store items.
source code
 
notifyIncomingRow(self, *args, **kwargs)
is called when certain grammars yield a row to the DC's belly.
source code
 
notifyIndexCreation(self, *args, **kwargs)
is called when an index on a DB table is created.
source code
 
notifyScriptRunning(self, *args, **kwargs)
is called when a script is being started.
source code
 
notifyError(self, *args, **kwargs)
is called when something wants to put out an error message.
source code
 
notifyFailure(self, *args, **kwargs)
is called when an unexpected twisted failure is being processed.
source code
 
notifyWarning(self, *args, **kwargs)
is called when something tries to emit communicate non-fatal trouble.
source code
 
notifyInfo(self, *args, **kwargs)
is called when something tries to emit auxiliary information.
source code
 
notifyDebug(self, *args, **kwargs)
is called when something wants to communicate information only useful when trying to figure out a malfunction.
source code
 
notifyWebServerUp(self, *args, **kwargs)
is called when the webserver is up and running.
source code
 
notifyDBTableModified(self, *args, **kwargs)
is called when an existing database table has been modified.
source code
 
subscribeDBTableModified(self, callback) source code
 
subscribeDebug(self, callback) source code
 
subscribeError(self, callback) source code
 
subscribeExceptionMutation(self, callback) source code
 
subscribeFailure(self, callback) source code
 
subscribeIncomingRow(self, callback) source code
 
subscribeIndexCreation(self, callback) source code
 
subscribeInfo(self, callback) source code
 
subscribeNewSource(self, callback) source code
 
subscribeScriptRunning(self, callback) source code
 
subscribeShipout(self, callback) source code
 
subscribeSourceError(self, callback) source code
 
subscribeSourceFinished(self, callback) source code
 
subscribeWarning(self, callback) source code
 
subscribeWebServerUp(self, callback) source code
 
unsubscribeDBTableModified(self, callback) source code
 
unsubscribeDebug(self, callback) source code
 
unsubscribeError(self, callback) source code
 
unsubscribeExceptionMutation(self, callback) source code
 
unsubscribeFailure(self, callback) source code
 
unsubscribeIncomingRow(self, callback) source code
 
unsubscribeIndexCreation(self, callback) source code
 
unsubscribeInfo(self, callback) source code
 
unsubscribeNewSource(self, callback) source code
 
unsubscribeScriptRunning(self, callback) source code
 
unsubscribeShipout(self, callback) source code
 
unsubscribeSourceError(self, callback) source code
 
unsubscribeSourceFinished(self, callback) source code
 
unsubscribeWarning(self, callback) source code
 
unsubscribeWebServerUp(self, callback) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  eventTypes = ['SourceError', 'SourceFinished', 'Error', 'Incom...
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

suspended(*args, **kwds)

source code 

a context manager suspending notification for a specific event.

This is mainly for use by test code that wants to avoid spilling too much junk into the log.

One weak point here is that any subscriptions entered while notification is suspended are lost. So: Don't suspend notifications for normal code.

Decorators:
  • @contextlib.contextmanager

unsubscribe(self, evName, callback)

source code 

removes a callback from evName's callback list.

It is not an error to unsubscribe a callback that's not subscribed.

notifyExceptionMutation(self, *args, **kwargs)

source code 

is called when an exception is being handled by raising newExc.

The callbacks are passed a pair of sys.exc_info() and newExc.

logOldExc(self, newExc)

source code 

notifies of and ExceptionMutation and returns newExc.

This is just a convenience when mutating exceptions.

notifyNewSource(self, *args, **kwargs)

source code 

is called when a new source is being operated on.

The callbacks are passed some, hopefully useful, token string. For file source, this is the file name, otherwise we try to make up something.

As side effects, the curSource attribute is set to this value.

notifySourceError(self, *args, **kwargs)

source code 

is called when a parse error occurred in a source.

The callbacks are passed the name of the failing source.

notifySourceFinished(self, *args, **kwargs)

source code 

is called when a source file has been processed.

The curSource attribute is updated, and its old value is propagated to the callbacks.

notifyShipout(self, *args, **kwargs)

source code 

is called when certain table implementations store items.

The number of items is passed on to the callbacks. As a side effect, the instance variable totalShippedOut is adjusted.

InMemoryTables don't call this right now and probably never will.

notifyIncomingRow(self, *args, **kwargs)

source code 

is called when certain grammars yield a row to the DC's belly.

The callbacks receive a reference to the row. As a side effect, the instance variable totalRead is bumped up, and lastRow becomes the row passed in.

To support this, RowIterators have to call this method in their _iterRows. Most will do, DictlistGrammars, e.g., don't.

notifyIndexCreation(self, *args, **kwargs)

source code 

is called when an index on a DB table is created.

The callbacks receive the index name.

notifyScriptRunning(self, *args, **kwargs)

source code 

is called when a script is being started.

The callback receives a scripting.ScriptRunner instance. You probably want to use the name attribute and not much else.

notifyError(self, *args, **kwargs)

source code 

is called when something wants to put out an error message.

The handlers receive the error message as-is.

In general, you will be in an exception context when you receive this error, but your handlers should not bomb out when you are not.

notifyFailure(self, *args, **kwargs)

source code 

is called when an unexpected twisted failure is being processed.

You should not listen on this, since the handler just receives None. Rather, these events are converted to ErrorOccurreds including the failure's traceback.

notifyWarning(self, *args, **kwargs)

source code 

is called when something tries to emit communicate non-fatal trouble.

The handlers receive the message as-is

notifyInfo(self, *args, **kwargs)

source code 

is called when something tries to emit auxiliary information.

The handlers receive the message as-is

notifyDebug(self, *args, **kwargs)

source code 

is called when something wants to communicate information only useful when trying to figure out a malfunction.

The handlers receive the message as-is.

notifyWebServerUp(self, *args, **kwargs)

source code 

is called when the webserver is up and running.

No arguments are transmitted.

notifyDBTableModified(self, *args, **kwargs)

source code 

is called when an existing database table has been modified.

The argument is the fully qualified table name.


Class Variable Details

eventTypes

Value:
['SourceError',
 'SourceFinished',
 'Error',
 'IncomingRow',
 'NewSource',
 'DBTableModified',
 'Info',
 'Debug',
...