[spambayes-dev] PGClassifier checked in

Meyer, Tony T.A.Meyer at massey.ac.nz
Thu Aug 7 18:22:24 EDT 2003


> The storage module gained two new classes:

And now a third:
     mySQLClassifier - a concrete implementation using the MySQLdb
module to
     access a mySQL database

> This code has a number of problems, not the least of which is 
> that none of the other modules and scripts in the system know 
> about it yet.

I still like your earlier suggestion, and that's what I implemented to
test it.
For example, in my config file:

    [Storage]
    persistent_storage_file:mysql::host=localhost dbname=bayes

And in pop3proxy.py (if this does get used, some sort of central
function that all the apps can use would be good, IMO).

        if self.useDB:
            if '::' in filename:
                available_sqls = {"mysql" : storage.mySQLClassifier,
                                  "pgsql" : storage.PGClassifier,
                                 }
                sql_type, rest = filename.split('::', 1)
                if available_sqls.has_key(sql_type.lower()):
                    self.bayes =
available_sqls[sql_type.lower()](filename)
                else:
                    # raise some sort of InvalidClassifierError
                    pass
            else:
                self.bayes = storage.DBDictClassifier(filename)
        ...

[I needed to change your ":" to a "::" because Windows & MacOS<10 use
":" in filenames, whereas I think "::" is a no-no on both, and hopefully
*nix users don't want to put their hammie.db file in a path with a "::"]

> * I've tried to break functionality into the two classes 
> in such a way that adding other SQLClassifier subclasses should be 
> reasonably easy,

I can certainly say that adding the mySQL subclass was very easy.  It's
possible that even more code could go into the base class - some of the
mySQL functions are very similar to the PG ones.  I'll let you figure
that out ;)

I'll leave the other things to those more experienced with SQL :)

=Tony Meyer



More information about the spambayes-dev mailing list