Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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()