ok

Mini Shell

Direktori : /lib/python3.6/site-packages/zope/event/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/zope/event/__pycache__/classhandler.cpython-36.pyc

3

(��V��@s&dZddlZiZddd�Zdd�ZdS)	a�Class-based event handlers


A light-weight event-handler framework based on event classes.

Handlers are registered for event classes:

    >>> import zope.event.classhandler

    >>> class MyEvent(object):
    ...     def __repr__(self):
    ...         return self.__class__.__name__

    >>> def handler1(event):
    ...     print("handler1 %r" % event)

    >>> zope.event.classhandler.handler(MyEvent, handler1)

Descriptor syntax:

    >>> @zope.event.classhandler.handler(MyEvent)
    ... def handler2(event):
    ...     print("handler2 %r" % event)

    >>> class MySubEvent(MyEvent):
    ...     pass

    >>> @zope.event.classhandler.handler(MySubEvent)
    ... def handler3(event):
    ...     print("handler3 %r" % event)


Subscribers are called in class method-resolution order, so only
new-style event classes are supported, and then by order of registry.

    >>> import zope.event
    >>> zope.event.notify(MySubEvent())
    handler3 MySubEvent
    handler1 MySubEvent
    handler2 MySubEvent

�NFcsT|dkr�fdd�Sts&tjjjt��tkr:|gt�<nt�j|�|rPtSdS)z�Define an event handler for a (new-style) class.

    This can be called with a class and a handler, or with just a
    class and the result used as a handler decorator.
    Ncst�|d�S)NT)�handler)�func)�event_class��"/usr/lib/python3.6/classhandler.py�<lambda>6szhandler.<locals>.<lambda>)�registry�zope�eventZsubscribers�append�dispatchr)rZhandler_Z	decoratorr)rrr/srcCs4x.|jjD]"}xtj|f�D]}||�qWq
WdS)N)�	__class__�__mro__r�get)r
rrrrrrCsr)NF)�__doc__Z
zope.eventr	rrrrrrr�<module>*s


Zerion Mini Shell 1.0