Пример #1
0
def updateFlags():
    logger.debug("Rebuilding index of flags...")
    ix = storage.open_index()

    flags = list(fm.flagORM.view(c.database.couchServer, 'typeViews/flag'))
    flags = fm.formatFlags(flags, True)

    currentFlags = set()
    indexedFlags = set()

    with ix.searcher() as searcher:
        writer = ix.writer()

        for fields in searcher.all_stored_fields():
            if fields["id"] not in currentFlags:
                writer.delete_by_term('id', fields["id"])
            else:
                indexedFlags.add(fields["id"])

    for flag in flags:
        labels = ", ".join(flag.labels)

        writer.update_document(title=flag.title,
            id=unicode(flag.id),
            description=flag.description,
            labels=labels,
            url=flag.url,
            userID=flag.userID,
            created=flag.created)
        currentFlags.add(flag.id)

    writer.commit()
Пример #2
0
    def GET(self):
        """
        """
        if self.env["cfg"].enablePublicPages and self.env["cfg"].enablePublicLabels:
            page = self.env["members"]["p"] \
                    if self.env["members"].has_key("p") else 1
            baseLabel = self.env["members"][0]

            if type(baseLabel) == list:
                baseLabel = "/".join(baseLabel)

            view = labelsViewTmpl(searchList=[self.tmplSearchList])

            labelRe = re.compile(baseLabel+'(.*)')

            matchedFlags = []
            labels = []
            flags = fm.listFlagsByUserID(self.session.id)
            for flag in flags:
                for label in flag.labels:
                    if labelRe.match(label):
                        labels.append(label)
                        matchedFlags.append(flag)

            if baseLabel in labels:
                labels.pop(labels.index(baseLabel))

            if self.env["cfg"].enableModalFlagDeletes:
                view.scripts = ["handlebars_1.0.min",
                        "jquery.json-2.4.min",
                        "adminModal.flagr",
                        "editForm.flagr",
                        "deleteFlagModal.flagr"]

            flags = fm.formatFlags(matchedFlags, False)

            flagsTmpl = flagsListTmpl(searchList=[self.tmplSearchList])
            flagsTmpl.flags = flags

            view.flags = str(flagsTmpl)

            view.labels = labels
            view.baseLabel = baseLabel

            return view
        else:
            self._404()
Пример #3
0
def flagSearch(queryString):
    flags = []
    ix = storage.open_index()

    with ix.searcher() as searcher:
        query = MultifieldParser(
            ["title",
            "description",
            "labels",
            "url"], ix.schema).parse(unicode(queryString))
        results = searcher.search(query)

        for result in results:
            flags.append(fm.flagORM.getByID(result["id"]))

    flags = fm.formatFlags(flags, False)

    return flags
Пример #4
0
def buildIndexes():
    logger.debug("Making new index of flags...")
    ix = storage.create_index(flagSchema)

    writer = ix.writer()

    flags = fm.flagORM.all()
    flags = fm.formatFlags(flags, True)

    for flag in flags:
        logger.debug("Flag: " +flag.id+" Indexed")
        labels = ", ".join(flag.labels)

        writer.update_document(title=flag.title,
            id=flag.id,
            description=flag.description,
            labels=labels,
            url=flag.url,
            userID=flag.userID,
            created=flag.created)

    writer.commit()