1234567891011121314151617181920212223242526272829303132333435 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- from typing import Callable, TYPE_CHECKING
- from blinker import Namespace
- _signals = Namespace()
- post_updated = _signals.signal('post_updated')
- if TYPE_CHECKING:
- from blinker import Signal
- def handler(event):
- # type:(Signal)->Callable[object, object]
- """Signal decorator to allow use of callback functions as class decorators."""
- def decorator(fn):
- def call(cls):
- event.connect(fn, sender=cls)
- return cls
- fn.call = call
- return fn
- return decorator
- def post_updated_handler(sender, document, **kwargs):
- print sender
- print document
|