Metadata-Version: 1.0
Name: zope.lifecycleevent
Version: 3.5.0
Summary: Life-cycle events
Home-page: http://pypi.python.org/pypi/zope.lifecycleevent
Author: Zope Corporation and Contributors
Author-email: zope3-dev@zope.org
License: ZPL 2.1
Description: zope.lifecycleevent
        *******************
        
        .. contents::
        
        Overview
        ========
        
        In Zope 3, 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.
        
        Change History
        ==============
        
        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
        
        Detailed Documentation
        **********************
        
        Life-cycle events
        =================
        
        In Zope 3, 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))
        
        Zope 3's Dublin Core Metadata for instance, rely on the bare
        ObjectCreatedEvent and ObjectModifiedEvent to record creation and
        modification times. Other 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, implements
        >>> class IFile(Interface):
        ...     data = Attribute("Data")
        ...
        
        >>> class File(object):
        ...     implements(IFile)
        ...
        
        >>> 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.
        
        In the following we use an IAttributes description to describe in more detail
        which parts of an object where modified :
        
        >>> file.data = "456"
        
        >>> from zope.dublincore.interfaces import IZopeDublinCore
        >>> from zope.interface import directlyProvides
        >>> from zope.annotation.interfaces import IAttributeAnnotatable
        >>> directlyProvides(file, IAttributeAnnotatable)
        
        >>> IZopeDublinCore(file).title = u"New title"
        >>> IZopeDublinCore(file).title = u"New description"
        
        >>> from zope.lifecycleevent import Attributes
        >>> event = ObjectModifiedEvent(
        ...     obj,
        ...     Attributes(IFile, 'data'),
        ...     Attributes(IZopeDublinCore, 'title', 'description'),
        ...     )
        >>> notify(event)
        
        This says we modified the file data and the DC title and description.
        
        Download
        ********
        
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Programming Language :: Python
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development
