Tony Meyer wrote:
>>>> I am looking for example usage of sb_xmlrpcsrv.py.
>>>
>>>
>>> I presume you mean sb_xmlrpcserver.py.
>>
>>
>> yes - the FAQ spells it to sb_xmlrpcsrv.py, see
>> http://spambayes.sourceforge.net/faq.html
> 
> 
> Thanks; I'll fix that.
> 
>>>> Is there any sample code available to train a given mail as ham/ spam?
>>>
>>>
>>> Have you looked at sb_client.py?  It classifies rather than  trains, 
>>> but
>>> it's not particularly different.
>>
>>
>> Thanks for that hint. Now digged deeper into sb_xmlrpcserver.py and I
>> see, that the hammie.Hammie.train() method is not available. I think
>> a patch like this is needed:
>>
>> --- sb_xmlrpcserver.py,orig     2006-03-14 10:20:15.000000000 +0100
>> +++ sb_xmlrpcserver.py  2006-03-14 10:44:34.629148074 +0100
>> @@ -60,6 +60,16 @@
>>              pass
>>          return xmlrpclib.Binary(hammie.Hammie.filter(self, msg, 
>> *extra))
>>
>> +    def train(self, msg, is_spam):
>> +        try:
>> +            msg = msg.data
>> +        except AttributeError:
>> +            pass
>> +        hammie.Hammie.train(self, msg, is_spam)
> 
> 
> As in the previous email, you'll also need to store() the classifier 
> here, or the changes won't be saved to disk.
> 
>> +
>> +       # how do I return "nothing"? (in C this would be a void 
>> function)
>> +       return xmlrpclib.Boolean(True)
>> +
>>
>>  def usage(code, msg=''):
>>      """Print usage message and sys.exit(code)."""
>>
>> A minor issue is, that I dont know, how I could return nothing (None?)
>> from that xmlrpc call - so I return a boolean True.
> 
> 
> You either just use "return" by itself (generally what is done) or  you
> can explicitly "return None" if that's what you'd rather do.  In  this
> case, you're returning at the end of the method, so you don't  have to
> have a return call at all.  For example:
> 
> +    def train(self, msg, is_spam):
> +        try:
> +            msg = msg.data
> +        except AttributeError:
> +            pass
> +        hammie.Hammie.train(self, msg, is_spam)
> +        hammie.Hammie.store()

I get this error message:
<Fault 1: 'exceptions.TypeError:unbound method store() must be called
with Hammie instance as first argument (got nothing instead)'>
(on the xmlrpc client side).

so I changed the suggested store call to:
hammie.Hammie.store(self)
is that right?

then I got this error message:
<Fault 1: 'exceptions.TypeError:cannot marshal None unless allow_none is
enabled'>

I had to put in the return again:
return xmlrpclib.Boolean(True)

with the hammie.Hammie.store(self) call the data is written back to
disk and the feedback to spambayes via an imap client (as I described
in another thread) works.

> 
> Would be all that is needed.
> 
>> Would such a patch be accepted?
> 
> 
> Yes.  I'll try and find time to check this in.
        
        thanks for that.

> =Tony.Meyer
> 
        thank for you help
        joerg

_______________________________________________
[email protected]
http://mail.python.org/mailman/listinfo/spambayes
Check the FAQ before asking: http://spambayes.sf.net/faq.html

Reply via email to