Changeset 2089 for TI07-MOLES/trunk/PythonCode
- Timestamp:
- 31/01/07 21:33:05 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/PythonCode/wsgi/ndgSearch.py
r2045 r2089 33 33 #self.server=loc.getDiscovery(readerclass=ExpatReaderClass, 34 34 self.server=loc.getDiscoveryServicePortType(readerclass=ExpatReaderClass,tracefile=tracefile) 35 self.serverSessionID=None 36 self.logger=logger 37 self.__reset() 38 39 def __reset(self): 40 ''' Initialise and/or making sure we have no hangovers from a previous call ''' 35 41 self.documents=None 36 42 self.hits=None 37 self.serverSessionID=None38 self.logger=logger39 43 self.error=None 40 44 self.response=None 45 self.status=None 41 46 42 47 def search(self,term,start=1,howmany=20,target='All',scope=None,bbox=None,dateRange=None,): 43 48 ''' Get a list of documents for a specific term using a free text search''' 44 49 45 50 self.__reset() 46 51 #if target=='Authors': 47 52 # request=doAuthorSearchRequest() … … 74 79 if self.logger: itime=time.time() 75 80 response=self.server.doSearch(request) 76 #try:77 #if target=='All':78 # response=self.server.doFullTextSearch(request)79 #elif target=='Authors':80 # response=self.server.doAuthorSearch(request)81 #elif target=='Params':82 # response=self.server.doParameterSearch(request)83 #else:84 # self.error=('Unknown search target type (%s)'%target,'programming error in backend')85 # return86 #except Exception,e:87 # raise Exception,e88 #self.error='Error: Unable to Carry Out Search','Internal error was (%s)'%e89 # return90 81 91 82 if self.logger: … … 139 130 etime=time.time()-itime 140 131 self.logger.info('Document Load [n=%s] took [%ss]'%(len(self.documents._document),etime)) 141 self.docs=docs 142 return self.docs 132 #self.docs=docs 133 #return self.docs 134 #removed self.docs reference Jan 31st, can't see why we had it ... 135 #nb returning a complete copy of the list didn't fix the problems with repeated calls 136 return docs 143 137 144 138 … … 178 172 ''' Returns all the documents in sequence in a labelled list of strings''' 179 173 if self.hits==0: return [] 180 filenames=self.documents.Document 174 #filenames=self.documents.Document 175 #so we know that the following call is the problem ... 181 176 responses=self.getAllDocs(format) 182 177 filenames=self.documents.Document … … 221 216 output=s.getLabelledDocs() 222 217 self.assertEqual(len(output),0) 218 219 def testSequence(self): 220 ''' Tests that repeated searches work and can support zero responses in the middle ''' 221 # this was a bug we found and needed a test case for 222 s=ndgSearch(tracefile=sys.stdout) 223 term='neodc' 224 r=s.search(term) 225 print s.hits 226 #if we uncomment this it breaks, if not it doesn't ... 227 #output=s.getLabelledDocs() 228 #this fails as well, and we've isolated the dependency in the previous call to 229 #be on this one: 230 res=s.getAllDocs() 231 #del(output) doesn't work ... 232 term='xpabnl' 233 r=s.search(term) 234 print s.hits 235 print 'Hopefully this is also zero: if not, expect the Sequence test to fail:',s.hits 236 #output=s.getLabelledDocs() 237 #self.assertEqual(len(output),0) 238 223 239 224 240 if __name__=="__main__":
Note: See TracChangeset
for help on using the changeset viewer.