Ejemplo n.º 1
0
    def get(self):
        # check memcache for main
        myfilter = self.request.get("filter", "") # returns name of disease to filter on
        if myfilter != "" and myfilter is not None:
            studies = Study.search_todict('"'+myfilter+'"')
            return self.out(rendered = self.render("studylistrender.html", studies = studies, filter=myfilter))

        page = self.request.get("page", "")
        pagenr = None
        if page == "":
            pagenr = 1
        else:
            try:
                pagenr = int(page)
            except:
                pagenr = 1

        # get pagenumber from diseasequery
        studies = self.studyquery.fetch_page(pagenr)

        # rendered = memcache.get("studylist_0:50")
        # if rendered is None:
            # make large query, to check for speed when cached
            # studies = Study.all().fetch(100)
        rendered = self.render("studylistrender.html",studies=studies, myfilter=myfilter, page=pagenr, count=self.count)
            # logging.debug(rendered )
            # add to memchache
            # if not memcache.add('studylist_0:50', rendered):
            #     logging.error("Memcache set failed.")

        self.out(rendered=rendered)
Ejemplo n.º 2
0
    def testSearchDocuments(self):
        """Test search document logic
        - try to add a study and fetch it using full-text search
        """
        disease_name = "Pizza"
        disease = Disease.get_or_insert(disease_name, name=disease_name)
        obj = {"pubmed_id": "123", "name": "How is the pizza?", "disease_ref": disease, "disease_trait": "Pizza"}

        study = Study.get_or_insert(
            obj["pubmed_id"],
            name=obj["name"],
            disease_ref=obj["disease_ref"],
            disease_trait=obj["disease_trait"],
            pubmed_id=obj["pubmed_id"],
            date=date.today(),
        )
        study.put()

        AddStudyDocument(study)
        result = Study.search_todict("123")
        self.assertEqual(obj["name"], result[0]["name"])  # result[0], obj)

        self.tSearchPage()
        self.tSearchStudy()
        self.tSearchDisease()