def before_update(self, mapper, connection, instance): from fulltext import get_writer # we need to update the fulltext instance for this bmark instance # we only do this for sqlite connections, else just pass instance.clean_content = self._clean_content(instance.content) b = instance.bmark writer = get_writer() writer.update_document( bid=unicode(b.bid), description=b.description if b.description else u"", extended=b.extended if b.extended else u"", tags=b.tag_str if b.tag_str else u"", readable=instance.clean_content, ) writer.commit()
def bmark_fulltext_insert_update(mapper, connection, target): """Update things before insert/update for the fulltext needs """ from fulltext import get_writer b = target writer = get_writer() writer.update_document( bid=unicode(b.bid), description=b.description if b.description else u"", extended=b.extended if b.extended else u"", tags=b.tag_str if b.tag_str else u"", readable=u"", ) writer.commit()
def sync_readable_content(mapper, connection, target): def _clean_content(content): if content: return u' '.join(BeautifulSoup(content).findAll(text=True)) else: return u"" from fulltext import get_writer # we need to update the fulltext instance for this bmark instance # we only do this for sqlite connections, else just pass target.clean_content = _clean_content(target.content) b = target.bmark writer = get_writer() writer.update_document( bid=unicode(b.bid), description=b.description if b.description else u"", extended=b.extended if b.extended else u"", tags=b.tag_str if b.tag_str else u"", readable=target.clean_content, ) writer.commit()