[Zope3-checkins] CVS: Zope3/src/zope/app/dublincore - creatorannotator.py:1.1 configure.zcml:1.3
Christian Theune
ct@gocept.com
Thu, 27 Mar 2003 07:52:17 -0500
Update of /cvs-repository/Zope3/src/zope/app/dublincore
In directory cvs.zope.org:/tmp/cvs-serv6346/dublincore
Modified Files:
configure.zcml
Added Files:
creatorannotator.py
Log Message:
- Added creator annotations which are set on the ObjectModified and ObjectCreated
events. They list all users that took part on authoring the content.
=== Added File Zope3/src/zope/app/dublincore/creatorannotator.py ===
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Object that takes care of annotating the dublin core creator field.
$Id: creatorannotator.py,v 1.1 2003/03/27 12:51:46 ctheune Exp $
"""
__metaclass__ = type
from zope.component import getAdapter
from zope.app.interfaces.dublincore import IZopeDublinCore
from zope.app.interfaces.event import ISubscriber
from zope.security.management import getSecurityManager
class CreatorAnnotatorClass:
"""Update Dublin-Core creator property
"""
__implements__ = ISubscriber
def notify(self, event):
dc = getAdapter(event.object, IZopeDublinCore)
if dc is None:
return
# Try to find a principal for that one. If there
# is no principal then we don't touch the list
# of creators.
principal = getSecurityManager().getPrincipal()
if principal is None:
return
principalid = principal.getId()
if not principalid in dc.creators:
dc.creators = dc.creators + (principalid, )
CreatorAnnotator = CreatorAnnotatorClass()
=== Zope3/src/zope/app/dublincore/configure.zcml 1.2 => 1.3 ===
--- Zope3/src/zope/app/dublincore/configure.zcml:1.2 Wed Dec 25 09:12:50 2002
+++ Zope3/src/zope/app/dublincore/configure.zcml Thu Mar 27 07:51:46 2003
@@ -18,4 +18,8 @@
event_types = "zope.app.interfaces.event.IObjectCreatedEvent"
/>
+ <event:subscribe
+ subscriber=".creatorannotator.CreatorAnnotator"
+ event_types="zope.app.interfaces.event.IObjectModifiedEvent zope.app.interfaces.event.IObjectCreatedEvent"/>
+
</zopeConfigure>