O'Reilly logo

Professional Plone Development: Building robust, content-centric web applications with Plone 3, an open source Content Management System by Martin Aspeli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9. Synchronous Events

One of the best things that Zope 3 gave Zope 2 is an events system. This makes it easy to emit events and register subscribers for those events from elsewhere. Events are synchronous—emitting code will block until all event handlers have completed—and unordered—there are no guarantees about the sequence in which event handlers are called.

Defining a new type of event is easy. All we need is an interface that identifies the event, and a concrete class implementing this.

>>> from zope.interface import Interface, Attribute >>> class INewGigEvent(Interface): ... """An event signaling that there's a new gig in town ... """ ... ... band = Attribute("Name of the band") >>> from zope.interface import implements >>> class NewGigEvent(object): ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required