Blog/Evolution-SpamBayes-Plugin-now-uses-DBus

The title says it all, i changed the xmlrpc system of the Evolution SpamBayes plugin to use DBus instead. The python dbus bindings have appeared in a brand new shiny version 0.80, which is sadly only available in Debian experimental - but it should arrive in etch after some time (hopefully).

The python dbus bindings look quite nice, they use the new decorator syntax, which is basically lisp for object oriented bigots, this defines a DBus method:

  1. class DBusHammie ( dbus.service.Object, hammie.Hammie ):
  2.     def __init__ ( self, bus, path, bayes ):
  3.         dbus.service.Object.__init__ ( self, bus, path )
  4.         hammie.Hammie.__init__ ( self, bayes )
  5.     @dbus.service.method ( 'net.halfdans.Spam', in_signature = 'ay', out_signature = 'i', byte_arrays = True )
  6.     def score ( self, msg ):
  7.         s = hammie.Hammie.score(self, msg)
  8.         return s

It's the @-part that are called decorators, decorators are better know to lisp people as second-order functions (if my memory serves me right) simply put: functions that return functions.

In work if have had exposure to the C# attributes, but they provide nowhere near the same degree of power as the Python syntax, just wanted to clear that up for no apparent reason. Some people seems to think that C# attributes are the best thing since sliced bread.

I named the DBus interface net.halfdans.Spam in the hope that it will be general enough for other spam engines to use the same interface and we can then provide spam filtering all over Gnome (and others using DBus) - once the interface becomes stable.

My final note would be that the evolution plugin (the C part of the plugin) still calls an external python program to filter spam, rather than use DBus directly. This will likely change in the future, it feels kind of to invoke Python just to open a DBus connection and pass an email message.

Comments (0)

Post comment

If you wish, you can use markdown syntax in the comment field.