'Dispatches an event.
Event handlers are looked up implicitly in the listeners\'
``__dict__``, so, if a listener only wants to handle ``DRAW``
events it should define a ``draw()`` method or pass
``only=["draw"]`` argument to :meth:`attach`.
.. warning::
If any of the attached listeners throws an exception, the
subsequent callbacks are be aborted.
:param str event: event to dispatch.
:param list args: arguments to pass to event handlers.'

def dispatch(self, event, *args, **kwargs):

    for (listener, only) in self.listeners:
        if (only and (event not in only)):
            continue
        try:
            handler = getattr(listener, event)
        except AttributeError:
            continue
        if hasattr(listener, u'__before__'):
            listener.__before__(event)
        handler(*args, **self.flags)
        if hasattr(listener, u'__after__'):
            listener.__after__(event)
    else:
        if kwargs.get(u'reset', True):
            self.reset()
