Mercurial > moin > 1.9
changeset 2068:7e2a9b7d2bc6
XML RPC functionality for the notification bot - the beginning
author | Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl> |
---|---|
date | Thu, 31 May 2007 01:19:49 +0200 |
parents | 3ca2b7065a05 |
children | 09eeb9cb9afc |
files | MoinMoin/jabber/main.py MoinMoin/jabber/xmlrpcbot.py |
diffstat | 2 files changed, 54 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/jabber/main.py Thu May 31 01:05:09 2007 +0200 +++ b/MoinMoin/jabber/main.py Thu May 31 01:19:49 2007 +0200 @@ -6,22 +6,28 @@ operations. Developed as a Google Summer of Code project. -@copyright: 2007 by Karol Nowak <grywacz@gmail.com> -@license: GNU GPL, see COPYING for details. + @copyright: 2007 by Karol Nowak <grywacz@gmail.com> + @license: GNU GPL, see COPYING for details. """ import sys from config import JabberConfig from xmppbot import XMPPBot +from xmlrpcbot import XMLRPCServer, XMLRPCClient from Queue import Queue def main(): - commands = Queue() - results = Queue() + commands_from_xmpp = Queue() + commands_to_xmpp = Queue() try: - bot = XMPPBot(JabberConfig, commands, results) - bot.start() + xmpp_bot = XMPPBot(JabberConfig, commands_from_xmpp, commands_to_xmpp) + xmlrpc_client = XMLRPCClient(commands_from_xmpp) + xmlrpc_server = XMLRPCServer(commands_to_xmpp) + + xmpp_bot.start() + xmlrpc_client.start() + xmlrpc_server.start() except KeyboardInterrupt, i: print i
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MoinMoin/jabber/xmlrpcbot.py Thu May 31 01:19:49 2007 +0200 @@ -0,0 +1,42 @@ +# -*- coding: iso-8859-1 -*- +""" + MoinMoin - a xmlrpc server and client for the notification bot + + This is a bot for notification and simple editing + operations. Developed as a Google Summer of Code + project. + + @copyright: 2007 by Karol Nowak <grywacz@gmail.com> + @license: GNU GPL, see COPYING for details. +""" + +from threading import Thread + +class Notification: + """Class representing a notification request""" + + def __init__(self, jid, text): + self.jid = jid + self.text = text + +class XMLRPCClient(Thread): + """XMLRPC Client + + It's responsible for performing XMLRPC operations on + a wiki, as inctructed by command objects received from + the XMPP component""" + + def __init__(self, commands): + Thread.__init__(self) + self.commands = commands + +class XMLRPCServer(Thread): + """XMLRPC Server + + It waits for notifications requests coming from wiki, + creates command objects and puts them on a queue for + later processing by the XMPP component""" + + def __init__(self, commands): + Thread.__init__(self) + self.commands = commands \ No newline at end of file