0001"""Sender classes."""
0002
0003
0004class _SENDER(type):
0005    """Base metaclass for sender classes."""
0006
0007    def __str__(cls):
0008        return '<Sender: %s>' % (cls.__name__, )
0009
0010
0011class Any(object):
0012    """Used to represent either 'any sender'.
0013
0014    The Any class can be used with connect, disconnect, send, or
0015    sendExact to denote that the sender paramater should react to any
0016    sender, not just a particular sender.
0017    """
0018
0019    __metaclass__ = _SENDER
0020
0021
0022class Anonymous(object):
0023    """Singleton used to signal 'anonymous sender'.
0024
0025    The Anonymous class is used to signal that the sender of a message
0026    is not specified (as distinct from being 'any sender').
0027    Registering callbacks for Anonymous will only receive messages
0028    sent without senders.  Sending with anonymous will only send
0029    messages to those receivers registered for Any or Anonymous.
0030
0031    Note: The default sender for connect is Any, while the default
0032    sender for send is Anonymous.  This has the effect that if you do
0033    not specify any senders in either function then all messages are
0034    routed as though there was a single sender (Anonymous) being used
0035    everywhere.
0036    """
0037
0038    __metaclass__ = _SENDER