skip montanaro dwooqfuuguserssourceforgenet update cvsrootspambayesspambayesspambayes directory sc8prcvs8sourceforgenettmpcvsserv23471spambayes modified files tag coresvr xmlrpcpluginpy log message docstring refine api bit index xmlrpcpluginpy rcs file cvsrootspambayesspambayesspambayesatticxmlrpcpluginpyv retrieving revision 1123 retrieving revision 1124 diff c2 r1123 r1124 xmlrpcpluginpy 2 jun 2007 214208 0000 1123 xmlrpcpluginpy 4 jun 2007 122833 0000 1124 16 import threading email import message message_from_string simplexmlrpcserver import simplexmlrpcserver simplexmlrpcrequesthandler 161 xmlrpc plugin spambayes core server plugin opens xmlrpc server separate thread listening given host port default localhost5001 python 25 later also enforces path default sbrpc security note xmlrpc plugin provide security would unwise listen anything besides localhost similarly running core_server configured xmlrpc plugin quite likely main core_server interface listen something localhost allow administrators administer remotely access url available set trusted administrators probably proxy webserver provides necessary authentication support xmlrpc server exposes following two methods scoreform_dict extra_tokens score evidence scores dictionary representing contents web submission form list extra tokens provided caller return value list containing spam probability input set token probability pairs significant tokens score_mimemsg encoding score evidence scores mime message string encoded using encoding return value score method trainform_dict extra_tokens is_spam trains given form tokens ham spam train_mimemsg encoding is_spam trains given mime message ham spam retrain nham nspam retrain scratch saved mime messages get_corpusis_spam string retrieve current ham spam corpus unix mbox format set_corpusstring is_spam set current ham spam corpus string unix mbox format normally followed call retrain following options available plugin section options xmlrpc_host host listen default localhost xmlrpc_port port listen default 5001 xmlrpc_path path support default sbrpc hambox path server ham corpus default tbd spambox path server spam corpus default tbd import threading import xmlrpclib email import message message_from_string simplexmlrpcserver import simplexmlrpcserver simplexmlrpcrequesthandler 1619 7176 plugin xmlrpc_host plugin xmlrpc_port plugin hambox plugin spambox 2753 path enforced python 25 later set anyway selfserverrequesthandlerclassrpc_paths path selfserverregister_functionselfscore selfserverregister_functionselfscore_mime selfthread threadingthreadtargetselfserverserve_forever selfthreadstart placeholders def scoreself form attachments extra_tokens mime_message form_to_mimeform attachments tokens return selfscore_mimemime_message def score_mimeself msg mime_type selfstatebayes none selfstatecreate_workers msg unicodemsg mime_type msg message_from_stringmsg tokens tokenizemsg return selfstatebayesspamprobtokens evidencetrue def form_to_mimeform attachments extra_tokens msg messagemessage msgset_typemultipartdigest main messagemessage mainset_payload joinstrv v formvalues msgattachmain msg_type content attachments 84145 path enforced python 25 later set anyway selfserverrequesthandlerclassrpc_paths path selfserverregister_instanceself selfthread threadingthreadtargetselfserverserve_forever selfthreadstart def _dispatchself method params method score score_mime train train_mime return getattrself methodparams elif method retrain get_corpus set_corpus return yet implemented method else raise xmlrpclibfault404 supported method def scoreself form_dict extra_tokens score dictionary extra tokens mime_message form_to_mimeform_dict extra_tokens return selfscore_mimemime_message def score_mimeself msg encoding score message representing mime document msg argument string given encoding tokens selftokenizemsg encoding return selfstatebayesspamprobtokens evidencetrue def trainself form_dict extra_tokens is_spam train form extra tokens mime_message form_to_mimeform_dict extra_tokens return selftrain_mimemime_message is_spam def train_mimeself msg is_spam train message tokens selftokenizemsg encoding return selfstatebayeslearntokens is_spam def tokenizeself msg encoding tokenize message make sure bayes instance available selfstatebayes none selfstatecreate_workers msg unicodemsg encoding msg message_from_stringmsg return tokenizemsg def form_to_mimeform mime_type extra_tokens encode submission form bits mime message form dictionary keyvalue pairs representing forms contents extra_tokens sequence synthetic tokens generated caller example include honeypot hidden field form might generate synthetic token tells filled might also generate tokens indicate long submitting username existed many successful posts username submitted msg messagemessage msgset_typemultipartdigest main messagemessage mainset_payload joinss k v k v formitems msgattachmain msg_type content attachments _______________________________________________ spambayescheckins mailing list pnperxdpvsarswdlppythonorg httpmailpythonorgmailmanlistinfospambayescheckins tue 05 aug 2008 172800 0700 spambayescheckins spambayesspambayes xmlrpcpluginpy 1123 1124