equal
deleted
inserted
replaced
322 """simple event / callback manager. |
322 """simple event / callback manager. |
323 |
323 |
324 Typical usage to register a callback:: |
324 Typical usage to register a callback:: |
325 |
325 |
326 >>> from cubicweb import CW_EVENT_MANAGER |
326 >>> from cubicweb import CW_EVENT_MANAGER |
327 >>> CW_EVENT_MANAGER.bind('after-source-reload', mycallback) |
327 >>> CW_EVENT_MANAGER.bind('after-registry-reload', mycallback) |
328 |
328 |
329 Typical usage to emit an event:: |
329 Typical usage to emit an event:: |
330 |
330 |
331 >>> from cubicweb import CW_EVENT_MANAGER |
331 >>> from cubicweb import CW_EVENT_MANAGER |
332 >>> CW_EVENT_MANAGER.emit('after-source-reload') |
332 >>> CW_EVENT_MANAGER.emit('after-registry-reload') |
333 |
333 |
334 emit() accepts an additional context parameter that will be passed |
334 emit() accepts an additional context parameter that will be passed |
335 to the callback if specified (and only in that case) |
335 to the callback if specified (and only in that case) |
336 """ |
336 """ |
337 def __init__(self): |
337 def __init__(self): |
351 |
351 |
352 def onevent(event): |
352 def onevent(event): |
353 """decorator to ease event / callback binding |
353 """decorator to ease event / callback binding |
354 |
354 |
355 >>> from cubicweb import onevent |
355 >>> from cubicweb import onevent |
356 >>> @onevent('before-source-reload') |
356 >>> @onevent('before-registry-reload') |
357 ... def mycallback(): |
357 ... def mycallback(): |
358 ... print 'hello' |
358 ... print 'hello' |
359 ... |
359 ... |
360 >>> |
360 >>> |
361 """ |
361 """ |