示例#1
0
    def _get_blog_search(self, par, xml=False):
        """ all blog articles matching search result """
        self._curpage = int(self._req.par('p', default_value = 1))

        self._obj['title'] = "Search"

        search = BlogSearch()
        result = search.get(par[0])
        
        newest = datetime.datetime.fromtimestamp(0)
        self._obj['data'] = []

        count = 0
        for r in result:
            count = count + 1

            logging.debug(r.doc_id)

            c = Content.get_by_key_name(r.doc_id)
            d = self.copy_bits(c)

            self._obj['data'].append(d)
            
            if c.sortdate > newest:
                newest = c.sortdate

        # fill in all our widgets        
        self._build_widgets_list(count, None)


        self._respond(path='blog-search', obj=self._obj, xml=xml, search={"term":par[0], "count": count})
示例#2
0
文件: route_api.py 项目: GAEBlog/blog
    def _update_search_index(self, parcontent):
        search = BlogSearch()

        search.insert_document(
            search.create_document(
                parcontent.key().name(),
                parcontent.sortdate,
                parcontent.author.displayname,
                parcontent.current.content,
                parcontent.current.title,
                parcontent.group.title,
            )
        )
示例#3
0
    def _get_reindex(self, par):
        q = Content.all()
        q.filter('status =', 'published')

        # date, author, content, title):
        search = BlogSearch()

        count = 0
        for c in q:
            count = count + 1
            search.insert_document(search.create_document(
                c.key().name(),
                c.sortdate,
                c.author.displayname,   
                c.current.content,
                c.current.title,
                c.group.title
            ))

        self._respond(["reindex"], opt={"count":count})