'Add an event handler for an event triggered by this object (subscribe).
eventType : event class object (e.g. ConnectionUp). If byName is True,
should be a string (e.g. "ConnectionUp")
handler : function/method to be invoked when event is raised
once : if True, this handler is removed after being fired once
weak : If handler is a method on object A, then listening to an event
on object B will normally make B have a reference to A, so A
can not be released until after B is released or the listener
is removed.
If weak is True, there is no relationship between the lifetimes
of the publisher and subscriber.
priority : The order in which to call event handlers if there are
multiple for an event type.  Should probably be an integer,
where higher means to call it earlier.  Do not specify if
you don\'t care.
byName : True if eventType is a string name, else an Event subclass
Raises an exception unless eventType is in the source\'s
_eventMixin_events set (or, alternately, _eventMixin_events must
be True).
The return value can be used for removing the listener.'

def addListener(self, eventType, handler, once=False, weak=False, priority=None, byName=False):

    self._eventMixin_init()
    if ((self._eventMixin_events is not True) and (eventType not in self._eventMixin_events)):
        fail = True
        if byName:
            for e in self._eventMixin_events:
                if issubclass(e, Event):
                    if (e.__name__ == eventType):
                        eventType = e
                        fail = False
                        break
        if fail:
            raise RuntimeError(('Event    %s    not    defined    on    object    of    type    %s' % (eventType, type(self))))
    if (eventType not in self._eventMixin_handlers):
        handlers = self._eventMixin_handlers[eventType] = []
        self._eventMixin_handlers[eventType] = handlers
    else:
        handlers = self._eventMixin_handlers[eventType]
    eid = _generateEventID()
    if weak:
        handler = CallProxy(self, handler, (eventType, eid))
    entry = (priority, handler, once, eid)
    handlers.append(entry)
    if (priority is not None):
        handlers.sort(reverse=True, key=operator.itemgetter(0))
    return (eventType, eid)
