Exemple #1
0
    def default(self, search, *args, **kw):
        results = set()
        search = search.strip()

        # Search name-version-release
        map(results.add, PackageUpdate.select(
            LIKE(PackageUpdate.q.title, '%%%s%%' % search),
                 orderBy=PackageUpdate.q.date_submitted))

        # Search bug numbers
        try:
            map(lambda bug: map(results.add, bug.updates),
                Bugzilla.select(Bugzilla.q.bz_id==int(search)))
        except ValueError: # can't convert search search to integer
            pass

        # Search CVEs
        if search.startswith('CVE') or search.startswith('CAN'):
            # Search bug titles for CVE, since that is how we track them now
            map(lambda bug: map(results.add, bug.updates),
                Bugzilla.select(LIKE(Bugzilla.q.title, '%%%s%%' % search)))

            # We still have some CVE objects lying around, so search them too
            map(lambda cve: map(results.add, cve.updates),
                CVE.select(CVE.q.cve_id==search))

        # If there is only 1 result, then jump right to it
        num_items = len(results)
        if len(results) == 1:
            raise redirect(results.pop().get_url())

        return dict(updates=list(results), num_items=num_items,
                    title="%d Results Found" % num_items)
Exemple #2
0
    def default(self, search, *args, **kw):
        results = set()
        search = search.strip()

        # Search name-version-release
        map(
            results.add,
            PackageUpdate.select(LIKE(PackageUpdate.q.title,
                                      '%%%s%%' % search),
                                 orderBy=PackageUpdate.q.date_submitted))

        # Search bug numbers
        try:
            map(lambda bug: map(results.add, bug.updates),
                Bugzilla.select(Bugzilla.q.bz_id == int(search)))
        except ValueError:  # can't convert search search to integer
            pass

        # Search CVEs
        if search.startswith('CVE') or search.startswith('CAN'):
            # Search bug titles for CVE, since that is how we track them now
            map(lambda bug: map(results.add, bug.updates),
                Bugzilla.select(LIKE(Bugzilla.q.title, '%%%s%%' % search)))

            # We still have some CVE objects lying around, so search them too
            map(lambda cve: map(results.add, cve.updates),
                CVE.select(CVE.q.cve_id == search))

        # If there is only 1 result, then jump right to it
        num_items = len(results)
        if len(results) == 1:
            raise redirect(results.pop().get_url())

        return dict(updates=list(results),
                    num_items=num_items,
                    title="%d Results Found" % num_items)