Mercurial > moin > 1.9
changeset 2069:09eeb9cb9afc
Actually send notifications. For now, only to me. :P
author | Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl> |
---|---|
date | Thu, 31 May 2007 21:21:38 +0200 |
parents | 7e2a9b7d2bc6 |
children | 4e123eb32380 |
files | MoinMoin/events/JabberNotification.py |
diffstat | 1 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/events/JabberNotification.py Thu May 31 01:19:49 2007 +0200 +++ b/MoinMoin/events/JabberNotification.py Thu May 31 21:21:38 2007 +0200 @@ -8,7 +8,30 @@ @license: GNU GPL, see COPYING for details. """ -# nothing here yet 8) +import xmlrpclib +from MoinMoin.events import PageEvent, PageChangedEvent + +server = None def handle(event): - print event \ No newline at end of file + global server + + if not isinstance(event, PageEvent) or event.request.cfg.bot_host is None: + return + + # Create an XML RPC server object only if it doesn't exist + if server is None: + server = xmlrpclib.Server("http://" + event.request.cfg.bot_host) + + msg = u"Page %(page_name)s has been modified!\n" % ( {'page_name': event.page.page_name} ) + + if event.comment: + msg = msg + u"The comment is: %(comment)s\n" % ( {'comment': event.comment} ) + + if event.trivial: + msg = msg + u"This change has been marked as TRIVIAL.\n" + + try: + server.send_notification(u"grzyw@jabber.org", msg) + except Exception, desc: + print "XML RPC error:", desc