def delete(cls, guid): logger = LoggerFactory.logger(cls.__name__) a_info = ArtifactInfo.get_by_guid(guid) a_content_key = ArtifactContent.get_by_guid(guid) if not (a_info or a_content_key): # neither record found raise NotFoundException("artifact %s" % guid) elif not (a_info and a_content_key): # one record found; one missing logger.warn("artifact %s; missing data; info=%s; content=%s" % (guid, a_info.key().name(), a_content_key)) # I delete what I can keys = [] if a_info: keys.append(a_info) if a_content_key: keys.append(a_content_key) db.delete(keys) # decrease source counter Counters.source_counter(a_info.source.name).decrement()
def _content_md5(cls, source_name, content_type, body): logger = LoggerFactory.logger(cls.__name__) # logger.debug("%s, %s, %s" % (source_name.__class__, content_type.__class__, body.__class__)) hasher = hashlib.md5() hasher.update("%s;%s;%r" % (source_name, content_type, body)) return hasher.hexdigest()