Skip to main content

Object life-cycle events

Project description

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.

Some examples:

>>> 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.

Changes

4.1.0 (2014-12-27)

  • Add support for PyPy3.

  • Add support for Python 3.4.

4.0.3 (2013-09-12)

  • Drop the dependency on zope.component as the interface and implementation of ObjectEvent is now in zope.interface. Retained the dependency for the tests.

  • Fix: .moved tried to notify the wrong event.

4.0.2 (2013-03-08)

  • Add Trove classifiers indicating CPython and PyPy support.

4.0.1 (2013-02-11)

  • Add tox.ini.

4.0.0 (2013-02-11)

  • Test coverage at 100%.

  • Add support for Python 3.3 and PyPy.

  • Replace deprecated zope.interface.implements usage with equivalent zope.interface.implementer decorator.

  • Drop support for Python 2.4 and 2.5.

3.7.0 (2011-03-17)

  • Add convenience functions to parallel zope.lifecycleevent.modified for the other events defined in this package.

3.6.2 (2010-09-25)

  • Add not declared, but needed test dependency on zope.component [test].

3.6.1 (2010-04-30)

  • Remove dependency on undeclared zope.testing.doctest.

3.6.0 (2009-12-29)

  • Refactor tests to lose zope.annotation and zope.dublincore as dependencies.

3.5.2 (2009-05-17)

  • Copy IObjectMovedEvent, IObjectAddedEvent, IObjectRemovedEvent interfaces and ObjectMovedEvent, ObjectAddedEvent and ObjectRemovedEvent classes 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).

3.5.1 (2009-03-09)

  • Remove deprecated code and therefore 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.

3.5.0 (2009-01-31)

  • Remove old module declarations from classes.

  • Use zope.container instead of zope.app.container.

3.4.0 (2007-09-01)

Initial release as an independent package

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zope.lifecycleevent-4.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zope.lifecycleevent-4.1.0-py2.py3-none-any.whl (11.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file zope.lifecycleevent-4.1.0.tar.gz.

File metadata

File hashes

Hashes for zope.lifecycleevent-4.1.0.tar.gz
Algorithm Hash digest
SHA256 e28e7a1e3e42ad5759ac1f57dae12f17e384df49cd94faae7ec841e23ad5b0c6
MD5 4fa9c3c7ec97f9c865d802c2f5b96839
BLAKE2b-256 27fd346b2f83049e451ee3c609d15ee183330e0adf48bb207a081c52263843f6

See more details on using hashes here.

File details

Details for the file zope.lifecycleevent-4.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for zope.lifecycleevent-4.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8448566637cd18d51efb3b589ef41e5eba1e3b27e6b1ee50688ce6ed71a9b7f0
MD5 d4f9f36a1a70fbccf382269c58bb60de
BLAKE2b-256 7303704ab8efa7121fe6ecb2c8ff137f5d70054ced4c5d789408e56190e8109f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page