Esempio n. 1
0
 def _createDocument(self, cursor, content_hash, title, text, fileSize,
                     lastModifiedOn, filename, state):
     doc = Document(document_id=content_hash,
                    title=title,
                    text=text,
                    size=fileSize,
                    publication_time=lastModifiedOn,
                    download_count=0.,
                    url=filename,
                    matching=0.,
                    indexed='1',
                    state=state)
     doc.commit(cursor, update=False)
     doc = Document.selectWhere(cursor, document_id=content_hash)[0]
     return doc
Esempio n. 2
0
    def _createDocument(self, cursor, futureDoc):

        doc = Document(document_id=futureDoc.content_hash,
                       title=futureDoc.title,
                       text=futureDoc.text[:MAX_STORED_SIZE],
                       size=futureDoc.fileSize,
                       publication_time=futureDoc.lastModificationTime,
                       download_count=0.,
                       url=futureDoc.filename,
                       mime_type=futureDoc.mime_type,
                       matching=0.,
                       indexed='1',
                       state=futureDoc.state)
        doc.commit(cursor, update=False)
        doc = Document.selectWhere(cursor, document_id=futureDoc.content_hash)[0]
        return doc
Esempio n. 3
0
 def testIsKnown(self):
     doc = Document(document_id='0' * 40)
     self.query.addMatch(doc.__dict__)
     self.failUnless(self.query.isKnown(doc.__dict__))
     self.failIf(self.query.isKnown(
         Document(document_id='1' * 40).__dict__))
Esempio n. 4
0
 def testAddMatch(self):
     doc = Document(document_id='0' * 40)
     self.query.addMatch(doc.__dict__)
     self.failUnless('0' * 40 in self.query.documents_ids)