changeset 2148:8181ec5cd86c

Merge with my devel branch.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 17 Jun 2007 15:26:20 +0200
parents 85854afc1aa2 (current diff) b01a6ef1be4c (diff)
children 7def1e49e757
files
diffstat 2 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Sun Jun 17 02:45:15 2007 +0200
+++ b/MoinMoin/config/multiconfig.py	Sun Jun 17 15:26:20 2007 +0200
@@ -662,6 +662,11 @@
         
         # check if jabber bot is available and set flag:
         self.jabber_enabled = self.bot_host is not None
+        
+        # if we are to use the jabber bot, instantiate a server object for future use
+        if self.jabber_enabled:
+            from xmlrpclib import Server
+            self.xmlrpc_server = Server("http://" + self.bot_host, )
 
         # Cache variables for the properties below
         self._iwid = self._iwid_full = self._meta_dict = None
--- a/MoinMoin/events/jabbernotify.py	Sun Jun 17 02:45:15 2007 +0200
+++ b/MoinMoin/events/jabbernotify.py	Sun Jun 17 15:26:20 2007 +0200
@@ -8,31 +8,20 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import xmlrpclib
-
 from MoinMoin.user import User, getUserList
 from MoinMoin.Page import Page
 
 import MoinMoin.events as ev
 from MoinMoin.events.messages import page_change_message
 
-# XML RPC Server object used to communicate with notification bot
-server = None
-
 
 def handle(event):
-    global server
-
     cfg = event.request.cfg
 
     # Check for desired event type and if notification bot is configured
     if not cfg.jabber_enabled:
         return
     
-    # Create an XML RPC server object only if it doesn't exist
-    if server is None:
-        server = xmlrpclib.Server("http://" + cfg.bot_host)
-    
     if isinstance(event, ev.PageChangedEvent):
         return handle_page_changed(event)
     elif isinstance(event, ev.JabberIDSetEvent) or isinstance(event, ev.JabberIDUnsetEvent):
@@ -49,6 +38,7 @@
     """ Handles events sent when user's JID changes """
     
     request = event.request
+    server = request.cfg.xmlrpc_server
     _ = request.getText
     
     try:
@@ -69,6 +59,7 @@
     """Handles event sent when a file is attached to a page"""
     
     request = event.request
+    server = request.cfg.xmlrpc_server
     page = Page(request, event.pagename) 
     
     subscribers = page.getSubscribers(request, return_users=1)
@@ -79,6 +70,7 @@
     """ Handles events related to page changes """
     
     request = event.request
+    server = request.cfg.xmlrpc_server
     page = event.page
     
     subscribers = page.getSubscribers(request, return_users=1, trivial=event.trivial)
@@ -89,6 +81,7 @@
     """Handles event sent when a page is deleted"""
     
     request = event.request
+    server = request.cfg.xmlrpc_server
     page = event.page
     
     subscribers = page.getSubscribers(request, return_users=1)
@@ -151,6 +144,7 @@
     @param trivial: the change is marked as trivial
     """
     _ = request.getText
+    server = request.cfg.xmlrpc_server
     
     for jid in jids:
         # FIXME: stops sending notifications on first error