[spambayes-dev] Re: Pickle vs DB inconsistencies

Tim Peters tim.one at comcast.net
Thu Jun 26 21:46:20 EDT 2003


[Tony Meyer]
> ...
> Here's example code:
>
> from spambayes.storage import DBDictClassifier
> from spambayes.classifier import WordInfo
> d = DBDictClassifier("fail.db")
> print "Should not be an entry"
> print d._wordinfoget("tok")
> w = WordInfo()
> w.hamcount = 1
> d._wordinfoset("tok", w)
> print "Should have a ham count of 1, spam count of 0"
> print d._wordinfoget("tok")
> w.hamcount -=1 # not really necessary
> d._wordinfodel("tok")
> #d.store()  # uncomment this line and it will work
> print "Should not be an entry (or have ham and spam of 0)"
> print d._wordinfoget("tok")

OK, I checked the change in I mentioned before, and now this program prints

"""
Should not be an entry
None
Should have a ham count of 1, spam count of 0
WordInfo(0, 1)
Should not be an entry (or have ham and spam of 0)
None
"""

Note that it should not have a spam and ham count of 0 at the end, it should
return None (as it does now).  As the WordInfo class comment says,

    # Invariant:  For use in a classifier database, at least one of
    # spamcount and hamcount must be non-zero.

I also checked in other, more cosmetic changes.  If it breaks something, let
me know.




More information about the spambayes-dev mailing list