Пример #1
0
 def onclose(tlcomp, srchcomp, wiki, byuser, log):
     log and tlcomp.log(byuser, log, wiki=wiki)
     log and srchcomp.indexwiki([wiki], replace=True)
Пример #2
0
    def search( self, environ ) :
        r"""
        ==== Xapian search indexing

        Build search index table for database content.

        > [<PRE paster request <.ini file> /pasteradmin/search <do> [doctypes] [replace=1] [querystring] [xid] >]

        where,
        :do :: 
          can be, \\ 
          //index//, to index all documents from tables mentioned in [doctypes] \\ 
          //queryterms//, convert the <querystring> and display the query terms \\ 
          //query//, results for <querystring> \\ 
          //clear//, remove the document identified by //xid//
        :doctypes ::
          Documents for which to build search index, can be a comma separated
          value of,
          [<PRE user, attach, license, staticwiki, project, ticket, review, wiki. >]
          If not specified, index will be built for all documents
        :replace ::
          Overwrite the existing index with new one. If not specified, replace
          will be False
        :querystring ::
          simple query string
        :xid ::
          document id, only for administrators who know what they are doing.
        """
        from zeta.config.environment    import srchcomp

        if environ['paste.command_request'] :
            args     = cmd_parse_request()
            do       = args.get( 'do', None )
            replace  = args.get( 'replace', None )
            doctypes = args.get( 'doctypes', '' )
            q        = args.get( 'q', None )
            xid      = args.get( 'xid', None )

            doctypes = h.parse_csv( doctypes )

        if do == 'index' and not doctypes :
            print "Indexing Users ...."
            srchcomp.indexuser( replace=replace, flush=False )
            print "Indexing Attachments ...."
            srchcomp.indexattach( replace=replace, flush=False )
            print "Indexing Licenses ...."
            srchcomp.indexlicense( replace=replace, flush=False )
            print "Indexing StaticWikis ...."
            srchcomp.indexstaticwiki( replace=replace, flush=False )
            print "Indexing Projects ...."
            srchcomp.indexproject( replace=replace, flush=False )
            print "Indexing Tickets ...."
            srchcomp.indexticket( replace=replace, flush=False )
            print "Indexing Reviews ...."
            srchcomp.indexreview( replace=replace, flush=False )
            print "Indexing Wikis ...."
            srchcomp.indexwiki( replace=replace, flush=False )
            srchcomp.close()

        elif do == 'index' :
            'user'       in doctypes and srchcomp.indexuser( replace=replace, flush=False)
            'attach'     in doctypes and srchcomp.indexattach( replace=replace, flush=False )
            'license'    in doctypes and srchcomp.indexlicense( replace=replace, flush=False )
            'staticwiki' in doctypes and srchcomp.indexstaticwiki( replace=replace, flush=False )
            'project'    in doctypes and srchcomp.indexproject( replace=replace, flush=False )
            'ticket'     in doctypes and srchcomp.indexticket( replace=replace, flush=False )
            'review'     in doctypes and srchcomp.indexreview( replace=replace, flush=False )
            'wiki'       in doctypes and srchcomp.indexwiki( replace=replace, flush=False)
            srchcomp.close()

        elif do == 'queryterms' and q :
            print srchcomp.queryterms(q)

        elif do == 'query' and q :
            matches = srchcomp.query( q )
            for m in matches :
                print "--------------------------"
                print "Percent : %s  Rank : %s  Weight : %s " % \
                      ( m.percent, m.rank, m.weight )
                print m.document.get_data()[:100]

        elif do == 'clear' and xid :
            srchcomp.clear( xid )
Пример #3
0
 def onclose(tlcomp, srchcomp, wiki, author, log):
     tlcomp.log(author, log, wiki=wiki)
     srchcomp.indexwiki([wiki], replace=True)