[spambayes-dev] close_db and change_db functions in sb_imapfilter.py

Sjoerd Mullender sjoerd at acm.org
Thu Dec 22 17:05:58 CET 2005


I just looked at the latest development on the Spambayes front and I was
wondering how the close_db and change_db callback functions are supposed
to work, especially the change_db function.

The way I understand change_db is that it is supposed to change the
values of classifier, message_db and imap_filter in the parent function
(the function run in which the callbacks are defined).  However, I don't
think that works.  The parent function variables are not available in
change_db, it only defines its own copies which are destroyed when the
function returns.

close_db may work since it doesn't assign to any variables and so only
refers to the variables defined in the parent function.

I would suggest a completely different way: at the top of the loop in
the run function, open the database and create the filter, and at the
end of the loop, before the sleep, close the database.  If it is
inefficient to open the database (e.g. when using a pickle), this may
not be a good idea, but otherwise I guess it's not too bad.

Alternatively, use a class and use instance variables for classifier et al.

-- 
Sjoerd Mullender
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 369 bytes
Desc: OpenPGP digital signature
Url : http://mail.python.org/pipermail/spambayes-dev/attachments/20051222/940c7b2b/signature.pgp


More information about the spambayes-dev mailing list