Object life-cycle events
In Zope, events are used by components to inform each other about relevant new objects and object modifications.
To keep all subscribers up to date it is indispensable that the life cycle of an object is accompanied by various events.
>>> from zope.event import notify >>> from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent>>> class Sample(object) : ... "Test class">>> obj = Sample() >>> notify(ObjectCreatedEvent(obj))>>> obj.modified = True >>> notify(ObjectModifiedEvent(obj))
Some event consumers like catalogs and caches may need more information to update themselves in an efficient manner. The necessary information can be provided as optional modification descriptions of the ObjectModifiedEvent.
>>> from zope.interface import Interface, Attribute, implementer >>> class IFile(Interface): ... data = Attribute("Data") ...>>> @implementer(IFile) ... class File(object): ... pass>>> file = File() >>> file.data = "123" >>> notify(ObjectModifiedEvent(obj, IFile))
This says that we modified something via IFile. Note that an interface is an acceptable description. In fact, we might allow pretty much anything as a description and it depends on your needs what kind of descriptions you use.
- Dropped the dependency on zope.component as the interface and implementation of ObjectEvent is now in zope.interface. Retained the dependency for the tests.
- Fixed: .moved tried to notify the wrong event.
- Add Trove classifiers indicating CPython and PyPy support.
- Test coverage at 100%.
- Added support for Python 3.3 and PyPy.
- Replaced deprecated zope.interface.implements usage with equivalent zope.interface.implementer decorator.
- Dropped support for Python 2.4 and 2.5.
- Added convenience functions to parallel zope.lifecycleevent.modified for the other events defined in this package.
- Added not declared, but needed test dependency on
- Removed dependency on undeclared zope.testing.doctest.
- Refactor tests to loose zope.annotation and zope.dublincore as dependencies.
- IObjectMovedEvent, IObjectAddedEvent, IObjectRemovedEvent interfaces and ObjectMovedEvent, ObjectAddedEvent and ObjectRemovedEvent classes copied here from zope.container (plus tests). The intent is to allow packages that rely on these interfaces or the event classes to rely on zope.lifecycleevent (which has few dependencies) instead of zope.container (which has many).
- Remove deprecated code and thus remove dependency on zope.deferredimport.
- Change package’s mailing list address to zope-dev at zope.org, as zope3-dev at zope.org is now retired.
- Update package’s description and documentation.
- Remove old module declarations from classes.
- Use zope.container instead of zope.app.container.
Initial release as an independent package