def editMetadata(self, obj, allowDiscussion=None, title=None, subject=None, description=None, contributors=None, effective_date=None, expiration_date=None, format=None, language=None, rights=None, **kwargs): # Responsible for setting metadata on a content object. # We assume the obj implements IDublinCoreMetadata. mt = getToolByName(self, 'portal_membership') if not mt.checkPermission(ModifyPortalContent, obj): # FIXME: Some scripts rely on this being string? raise Unauthorized REQUEST = self.REQUEST pfx = self.field_prefix def getfield(request, name, default=None, pfx=pfx): return request.form.get(pfx + name, default) def tuplify(value): return tuple(filter(None, value)) if IDublinCore.providedBy(obj): if title is None: title = getfield(REQUEST, 'title') if description is None: description = getfield(REQUEST, 'description') if subject is None: subject = getfield(REQUEST, 'subject') if subject is not None: subject = tuplify(subject) if contributors is None: contributors = getfield(REQUEST, 'contributors') if contributors is not None: contributors = tuplify(contributors) if effective_date is None: effective_date = getfield(REQUEST, 'effective_date') if effective_date == '': effective_date = 'None' if expiration_date is None: expiration_date = getfield(REQUEST, 'expiration_date') if expiration_date == '': expiration_date = 'None' if IMutableDublinCore.providedBy(obj): if title is not None: obj.setTitle(title) if description is not None: obj.setDescription(description) if subject is not None: obj.setSubject(subject) if contributors is not None: obj.setContributors(contributors) if effective_date is not None: obj.setEffectiveDate(effective_date) if expiration_date is not None: obj.setExpirationDate(expiration_date) if format is not None: obj.setFormat(format) if language is not None: obj.setLanguage(language) if rights is not None: obj.setRights(rights) # Make the catalog aware of changes obj.reindexObject()
def editMetadata(self, obj, allowDiscussion=None, title=None, subject=None, description=None, contributors=None, effective_date=None, expiration_date=None, format=None, language=None, rights=None, **kwargs): # Responsible for setting metadata on a content object. # We assume the obj implements IDublinCoreMetadata. mt = getToolByName(self, 'portal_membership') if not mt.checkPermission(ModifyPortalContent, obj): # FIXME: Some scripts rely on this being string? raise Unauthorized REQUEST = self.REQUEST pfx = self.field_prefix def getfield(request, name, default=None, pfx=pfx): return request.form.get(pfx + name, default) def tuplify(value): return tuple(filter(None, value)) if IDublinCore.providedBy(obj): if title is None: title = getfield(REQUEST, 'title') if description is None: description = getfield(REQUEST, 'description') if subject is None: subject = getfield(REQUEST, 'subject') if subject is not None: subject = tuplify(subject) if contributors is None: contributors = getfield(REQUEST, 'contributors') if contributors is not None: contributors = tuplify(contributors) if effective_date is None: effective_date = getfield(REQUEST, 'effective_date') if effective_date == '': effective_date = 'None' if expiration_date is None: expiration_date = getfield(REQUEST, 'expiration_date') if expiration_date == '': expiration_date = 'None' if IMutableDublinCore.providedBy(obj): if title is not None: obj.setTitle(title) if description is not None: obj.setDescription(description) if subject is not None: obj.setSubject(subject) if contributors is not None: obj.setContributors(contributors) if effective_date is not None: obj.setEffectiveDate(effective_date) if expiration_date is not None: obj.setExpirationDate(expiration_date) if format is not None: obj.setFormat(format) if language is not None: obj.setLanguage(language) if rights is not None: obj.setRights(rights) # Make the catalog aware of changes obj.reindexObject()