def _renameAfterCreation(self, check_auto_id=False): """ Renames an object like its normalized title. Overridden method """ if check_auto_id and not self._isIDAutoGenerated(self.getId()): # No auto generated id return False # Check if hook method is there if hasattr(self, 'getEntryId'): new_id = self.getEntryId() if new_id: invalid_id = False check_id = getattr(self, 'check_id', None) if check_id is not None: invalid_id = check_id(new_id, required=1) else: # If check_id is not available just look for conflicting ids parent = aq_parent(aq_inner(self)) invalid_id = new_id in parent.objectIds() if not invalid_id: # Can't rename without a subtransaction commit when using # portal_factory! get_transaction().commit(1) self.setId(new_id) return new_id return BaseContent._renameAfterCreation(self, check_auto_id)
def _renameAfterCreation(self, check_auto_id=False): """ Renames an object like its normalized title. Overridden method """ if check_auto_id and not self._isIDAutoGenerated(self.getId()): # No auto generated id return False # Check if hook method is there if hasattr(self, "getEntryId"): new_id = self.getEntryId() if new_id: invalid_id = False check_id = getattr(self, "check_id", None) if check_id is not None: invalid_id = check_id(new_id, required=1) else: # If check_id is not available just look for conflicting ids parent = aq_parent(aq_inner(self)) invalid_id = new_id in parent.objectIds() if not invalid_id: # Can't rename without a subtransaction commit when using # portal_factory! get_transaction().commit(1) self.setId(new_id) return new_id return BaseContent._renameAfterCreation(self, check_auto_id)
def _notifyOfCopyTo(self, container, op=0): """Retain the reference after copy, even though the Archetypes people really don't want us to.""" #log("_notifyOfCopyTo %s\n" % str(self)) refField = self.Schema().get('reference') refFieldValue = refField.get(self) self.copiedReference = refFieldValue return BaseContent._notifyOfCopyTo(self, container, op=op)
def setId(self, value): "Update any weblog entries using this topic" oldid = self.getId() BaseContent.setId(self, value) path = "/".join(self.getPhysicalPath()[:-1]) entries = self.portal_catalog( meta_type=["WeblogEntry"], path={"query": path, "level": 0}, getEntryCategories=oldid ) for entry in entries: o = entry.getObject() newcats = [] for cat in o.getEntryCategories(): if cat == oldid: newcats.append(value) else: newcats.append(cat) o.setEntryCategories(newcats) o.reindexObject()
def setId(self, value): "Update any weblog entries using this topic" oldid = self.getId() BaseContent.setId(self, value) path = '/'.join(self.getPhysicalPath()[:-1]) entries = self.portal_catalog( meta_type=['WeblogEntry',], path={'query':path, 'level': 0}, getEntryCategories = oldid, ) for entry in entries: o = entry.getObject() newcats = [] for cat in o.getEntryCategories(): if cat == oldid: newcats.append(value) else: newcats.append(cat) o.setEntryCategories(newcats) o.reindexObject()
def manage_afterAdd(self, item, container): """Retain the reference after copy, even though the Archetypes people really don't want us to.""" # find out if we got copied isCopy = getattr(item, '_v_is_cp', False) # make a copy of the reference if isCopy: refField = self.Schema().get('reference') refFieldValue = refField.get(self) \ or self.copiedReference # let the super class do its thing retVal = BaseContent.manage_afterAdd(self, item, container) # put the reference back if isCopy and refFieldValue: refField.set(self, refFieldValue) # sync the result objects (totally unrelated to the previous # code) self.syncResults('add') return retVal
def manage_beforeDelete(self, item, container): retVal = BaseContent.manage_beforeDelete(self, item, container) self.syncResults('delete') return retVal
def manage_afterAdd(self, item, container): retVal = BaseContent.manage_afterAdd(self, item, container) self.syncResults('add') return retVal