[Zope3-dev] Should unindexing an non-indexed document raise an
exception? (was Re: [Zope3-checkins] SVN:
Zope3/branches/jim-index-restructure-2004-12/src/zope/index/
Updated IInjection to emphasize indexing of values (for documents),)
Jim Fulton
jim at zope.com
Mon Dec 6 16:48:24 EST 2004
Florent Guillaume wrote:
> Jim wrote:
>
>>Log message for revision 28574:
>
> [...]
>
>>-=-
>>Added: Zope3/branches/jim-index-restructure-2004-12/src/zope/index/field/README.txt
>>===================================================================
>
> [...]
>
>>+Unindexing a document id that isn't present is ignored:
>>+
>>+ >>> index.unindex_doc(8)
>>+ >>> index.unindex_doc(80)
>>+ >>> index.documentCount()
>>+ 8
>>+ >>> index.wordCount()
>>+ 7
>
>
> Why? I'd rather have it raise a KeyError... Code that really knows that
> it wants to ignore it can catch the exception. Other code that unindexes
> a document it thinks is there should fail IMHO.
We inevitably want such code to suceed. We'd end up needing exception
handlers in lots of inconvenient places. I'd really rather not incur
that pain.
I'm also not sure that it's worthwhile for the index to keep track.
For example, suppose we has a text index and were asked to index an empty
doc. Do we want to insist that the index keep a reverse entry for the
document? If we didn't, we couldn't distinguish between the "didn't index"
case and the "nothing to index" case.
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list