[Zope-CVS] CVS: Products/ZCTextIndex - BaseIndex.py:1.25 IIndex.py:1.10 ZCTextIndex.py:1.26

Casey Duncan casey@zope.com
Thu, 6 Jun 2002 15:48:26 -0400


Update of /cvs-repository/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv14938

Modified Files:
	BaseIndex.py IIndex.py ZCTextIndex.py 
Log Message:
Added has_doc method to Index API.
Allows clean implementation of ZCTextIndex's unindex_object method so that it plays better with ZCatalog's unindex behavior.


=== Products/ZCTextIndex/BaseIndex.py 1.24 => 1.25 ===
         # becomes the value of _docweight[docid].
         raise NotImplementedError
+        
+    def has_doc(self, docid):
+        return self._docwords.has_key(docid)
 
     # A subclass may wish to extend or override this.
     def unindex_doc(self, docid):


=== Products/ZCTextIndex/IIndex.py 1.9 => 1.10 ===
     def unindex_doc(docid):
         "XXX"
+        
+    def has_doc(docid):
+        """Returns true if docid is an id of a document in the index"""


=== Products/ZCTextIndex/ZCTextIndex.py 1.25 => 1.26 ===
 
     def unindex_object(self, docid):
-        self.index.unindex_doc(docid)
-        self._p_changed = 1 # XXX
+        if self.index.has_doc(docid):
+            self.index.unindex_doc(docid)
+            self._p_changed = 1 # XXX
 
     def _apply_index(self, request, cid=''):
         """Apply query specified by request, a mapping containing the query.