def delete_all(searchSel): completeSuccess = True searchFile = None for objstr in searchSel: success,objID,version = ryw.split_objstr(objstr) if not success: ryw.give_bad_news('DelSearchAll: invalid objstr: ' + objstr, logging.error) completeSuccess = False continue success,searchFile = DeleteObject.do_delete( objID, version, searchFile=searchFile) if not success: ryw.give_bad_news( 'DelSearchAll: DeleteObject.do_delete failed.' + objstr, logging.error) completeSuccess = False else: ryw.db_print('DelSearchAll.delete_all: do_delete succeeded.', 18) if searchFile: searchFile.done() return completeSuccess
def is_valid_local_object(objstr, repositoryRoot, searchFile): """a small helper function.""" success,objID,objVersion = ryw.split_objstr(objstr) if not success: logging.warning('ReverseLists.is_valid_local_object: ' + 'failed to split: ' + objstr) return False success,meta = searchFile.get_meta(objID, objVersion) return success and meta
def __add_many_mappings_memory(self, listName, itemsList): """called by add() and redefine(). returns changed. only touches memory, so the wrapper flushes disk.""" ryw.db_print('add_many_mappings_memory entered: container: ' + listName + ' , containees: ' + repr(itemsList), 17) incomeSet = set(itemsList) if incomeSet == set([]): return False changed = False for containee in incomeSet: success,containeeID,containeeVersion = \ ryw.split_objstr(containee) if not success: logging.warning('ReverseLists.add: failed to split: ' + containee) if self.reverseDict.has_key(containee): del self.reverseDict[containee] changed = True continue # # this deals with the case when a container (list) # contains dead objects (containees). # so if we can't find the containees, # we not only skip adding, but also want to try # to remove the containee from the ReverseLists. # #success,meta,objroot = ryw_meta.get_meta2( # self.repositoryRoot, containeeID, containeeVersion) success,meta = self.searchFile.get_meta( containeeID, containeeVersion) if not success: logging.warning('ReverseLists.add: failed get_meta: '+ containee) if self.reverseDict.has_key(containee): del self.reverseDict[containee] changed = True continue # # now we add the singleton. # changed = True self._ReverseLists__union_one_mapping(containee, [listName]) return changed
def lookup(self, containee): """returns a list of containers, each of which is a triplet: objstr, alias, and title string. write lock should be held because we might need to delete obsolete containers. called by the object display code.""" #logging.debug('ReverseLists.lookup: containee = ' + containee) #logging.debug('ReverseLists.lookup: dict is: ' + # repr(self.reverseDict)) if not self.reverseDict.has_key(containee): #logging.debug('ReverseLists.lookup: containee not found.') return [] containers = self.reverseDict[containee] containerInfo = [] obsoleteContainers = [] for container in containers: #logging.debug('ReverseLists.lookup: container is ' + # container) success,containerID,containerVersion = \ ryw.split_objstr(container) if not success: obsoleteContainers.append(container) logging.warning('ReverseLists.lookup: failed splitting: '+ container) continue if not self.searchFile: ryw.give_bad_news('ReverseLists.lookup: no searchFile.', logging.critical) raise NameError('ReverseLists.lookup: no searchFile.') if not is_in_container_file(containerID, containerVersion, containee, self.searchFile, self.repositoryRoot): obsoleteContainers.append(container) logging.info('ReverseLists.lookup: obsolete mapping: ' + containee + ' -> ' + container) continue # # now get the metadata so we can retrieve its # alias and title. # success,meta = self.searchFile.get_meta(containerID, containerVersion) if success: ryw.db_print('ReverseLists.lookup: fast seachFile done!', 10) else: obsoleteContainers.append(container) logging.warning('ReverseLists.lookup: failed searchFile ' + 'lookup: '+ container) continue #success,meta,objroot = ryw_meta.get_meta2( # repositoryRoot, containerID, containerVersion) #if not success: # obsoleteContainers.append(container) # logging.warning('ReverseLists.lookup: failed get_meta2: '+ # container) # continue alias = 'unnamed' title = 'unnamed' if meta.has_key('content_alias'): alias = meta['content_alias'] if meta.has_key('title'): title = meta['title'] containerInfo.append([container, alias, title]) ryw.db_print('ReverseLists.lookup: appending good: ' + repr([container, alias, title]), 10) if obsoleteContainers: self._ReverseLists__remove_obsolete_containers( containee, obsoleteContainers) #logging.debug('ReverseLists.lookup: ' + repr(containerInfo)) return containerInfo