def loadOrNewLink(self, url, documento): link = ls.findByUrl(url) if link is None: link = Link() link.url = url host = hs.findByUrl(url) link.host = host link.host_id = host.id link.ultimaColeta = datetime.datetime.now() link = ls.save(link) else: link.ultimaColeta = datetime.datetime.now() link = ls.update(link) return link
def inserirSemente(self, url): link = Link() linkOld = Link() linkOld = self.findByUrl(url) if linkOld is None: host = Host() host = hs.createUpdateHost(url) link.host_id = host.id link.host = host link.url = url link = self.save(link) else: link = linkOld return link