[Checkins] SVN: grokcore.component/trunk/README.txt document
@grokcore.component.subscriber()
Philipp von Weitershausen
philikon at philikon.de
Fri May 2 05:54:50 EDT 2008
Log message for revision 86067:
document @grokcore.component.subscriber()
Changed:
U grokcore.component/trunk/README.txt
-=-
Modified: grokcore.component/trunk/README.txt
===================================================================
--- grokcore.component/trunk/README.txt 2008-05-02 09:53:40 UTC (rev 86066)
+++ grokcore.component/trunk/README.txt 2008-05-02 09:54:50 UTC (rev 86067)
@@ -152,6 +152,27 @@
direct=True)
+Subscriber
+----------
+
+Here we see a subscriber much like it occurs within Zope itself. It
+subscribes to the modified event for all annotatable objects (in other
+words, objects that can have metadata associated with them). When
+invoked, it updates the Dublin Core 'Modified' property accordingly::
+
+ import datetime
+ import grokcore.component
+ from zope.annotation.interfaces import IAnnotatable
+ from zope.lifecycleevent.interfaces import IObjectModifiedEvent
+ from zope.dublincore.interfaces import IZopeDublinCore
+
+ @grokcore.component.subscriber(IAnnotatable, IObjectModifiedEvent)
+ def updateDublinCoreAfterModification(obj, event):
+ """Updated the Dublin Core 'Modified' property when a modified
+ event is sent for an object."""
+ IZopeDublinCore(obj).modified = datetime.datetime.now()
+
+
API overview
============
More information about the Checkins
mailing list