changeset 2170:3cfc01315d3a

Merge with my devel branch.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Tue, 19 Jun 2007 20:53:24 +0200
parents e6dd69d3ac69 (current diff) 8aad85519f76 (diff)
children a3a19bdc0b9a
files
diffstat 5 files changed, 57 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/_tests/test_xmlrpc_multicall.py	Tue Jun 19 20:53:24 2007 +0200
@@ -0,0 +1,28 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - MoinMoin.xmlrpc.xmlrpc_system_multicall Fault serialization
+
+    @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.xmlrpc import XmlRpcBase
+from MoinMoin.request.CLI import Request
+from xmlrpclib import Fault
+
+def xmlrpc_return_fault():
+    return Fault(666, "Fault description")
+
+def test_fault_serialization():
+    xmlrpc = XmlRpcBase(Request())
+    xmlrpc.xmlrpc_return_fault = xmlrpc_return_fault
+    args = [{'methodName': 'return_fault', 'params': [ ]}]
+    
+    print """If a XML RPC method returns a Fault, we should get a failure response
+    instead of a serialized Fault, as it happened in the past. See revision
+    8b7d6d70fc95 for details"""
+    
+    result = xmlrpc.xmlrpc_system_multicall(args)
+    assert(type(result[0]) == dict)
+    assert(result[0].has_key("faultCode") and result[0].has_key("faultString"))
+    
\ No newline at end of file
--- a/MoinMoin/events/emailnotify.py	Mon Jun 18 15:15:39 2007 +0200
+++ b/MoinMoin/events/emailnotify.py	Tue Jun 19 20:53:24 2007 +0200
@@ -16,7 +16,7 @@
 from MoinMoin.events.messages import page_change_message
 
 
-def sendNotification(request, page, comment, emails, email_lang, revisions, trivial):
+def send_notification(request, page, comment, emails, email_lang, revisions, trivial):
     """ Send notification email for a single language.
 
     @param comment: editor's comment given when saving the page
@@ -41,7 +41,7 @@
         mailBody, mail_from=page.cfg.mail_from)
 
 
-def notifySubscribers(request, page, comment, trivial):
+def notify_subscribers(request, page, comment, trivial):
     """ Send email to all subscribers of given page.
 
     @param comment: editor's comment given when saving the page
@@ -61,7 +61,7 @@
         for lang in subscribers:
             emails = [u.email for u in subscribers[lang]]
             names = [u.name for u in subscribers[lang]]
-            mailok, status = sendNotification(request, page, comment, emails, lang, revisions, trivial)
+            mailok, status = send_notification(request, page, comment, emails, lang, revisions, trivial)
             recipients = ", ".join(names)
             results.append(_('[%(lang)s] %(recipients)s: %(status)s') % {
                 'lang': lang, 'recipients': recipients, 'status': status})
@@ -81,4 +81,4 @@
     if not event.request.cfg.mail_enabled:
         return
     
-    return notifySubscribers(event.request, event.page, event.comment, event.trivial)
+    return notify_subscribers(event.request, event.page, event.comment, event.trivial)
--- a/MoinMoin/userform.py	Mon Jun 18 15:15:39 2007 +0200
+++ b/MoinMoin/userform.py	Tue Jun 19 20:53:24 2007 +0200
@@ -333,7 +333,7 @@
         
         # subscription to various events
         available = events.get_subscribable_events()
-        theuser.subscribed_events = [ev for ev in form.get('events')]
+        theuser.subscribed_events = [ev for ev in form.get('events', [])]
 
         # save data
         theuser.save()
--- a/jabberbot/xmlrpcbot.py	Mon Jun 18 15:15:39 2007 +0200
+++ b/jabberbot/xmlrpcbot.py	Tue Jun 19 20:53:24 2007 +0200
@@ -8,6 +8,7 @@
 
 import Queue
 import time, xmlrpclib
+import datetime
 from threading import Thread
 from SimpleXMLRPCServer import SimpleXMLRPCServer
 
@@ -161,7 +162,28 @@
             token_result, getpageinfo_result = self.multicall()
         
         # FIXME: warn if token turned out being wrong
-        command.data = getpageinfo_result[0]
+        
+        author = getpageinfo_result[0]['author']
+        if author.startswith("Self:"):
+            author = getpageinfo_result[0]['author'][5:]
+        
+        datestr = str(getpageinfo_result[0]['lastModified'])
+        date = u"%(year)s-%(month)s-%(day)s at %(time)s" % {
+                    'year': datestr[:4],
+                    'month': datestr[4:6],
+                    'day': datestr[6:8],
+                    'time': datestr[9:17],
+                }
+        
+        msg = u"""Last author: %(author)s
+Last modification: %(modification)s
+Current version: %(version)s""" % {
+             'author': author,
+             'modification': date,
+             'version': getpageinfo_result[0]['version'],
+         }
+        
+        command.data = msg
         
     get_page_info = _xmlrpc_decorator(get_page_info)
 
--- a/jabberbot/xmppbot.py	Mon Jun 18 15:15:39 2007 +0200
+++ b/jabberbot/xmppbot.py	Tue Jun 19 20:53:24 2007 +0200
@@ -215,7 +215,7 @@
             self.send_message(command.jid, msg % (pagelist, ))
             
         elif isinstance(command, cmd.GetPageInfo):
-            msg = u"""Here's some more detailed information on page "%s":\n\n%s"""
+            msg = u"""Following detailed information on page "%s" is available::\n\n%s"""
             self.send_message(command.jid, msg % (command.pagename, command.data))
             
     def ask_for_subscription(self, jid):