def ModifiedAnnotator(event): dc = IZopeDublinCore(event.object, None) if dc is not None: # Principals that can modify objects do not necessary have permissions # to arbitrarily modify DC data, see issue 373 dc = removeSecurityProxy(dc) dc.modified = datetime.now(pytz.utc)
def CreatorAnnotator(event): """Update Dublin-Core creator property""" dc = IZopeDublinCore(event.object, None) # Principals that can create object do not necessarily have # 'zope.app.dublincore.change' permission. See issue 373. dc = removeSecurityProxy(dc) 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. interaction = queryInteraction() if interaction is not None: for participation in interaction.participations: principalid = participation.principal.id if not principalid in dc.creators: dc.creators = dc.creators + (unicode(principalid), )
def edit(self): request = self.request formatter = self.request.locale.dates.getFormatter('dateTime', 'medium') dc = IZopeDublinCore(self.context) message='' if 'dctitle' in request: dc.title = unicode(request['dctitle']) dc.description = unicode(request['dcdescription']) description = Attributes(IZopeDublinCore, 'title', 'description') notify(ObjectModifiedEvent(self.context, description)) message = _("Changed data ${datetime}", mapping={'datetime': formatter.format(datetime.utcnow())}) return { 'message': message, 'dctitle': dc.title, 'dcdescription': dc.description, 'modified': (dc.modified or dc.created) and \ formatter.format(dc.modified or dc.created) or '', 'created': dc.created and formatter.format(dc.created) or '', 'creators': dc.creators }