Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
jabberbot.xmlrpcbot Namespace Reference

Classes

class  ConfigurationError
class  XMLRPCClient
class  XMLRPCServer

Functions

def _xmlrpc_decorator

Variables

 token
 multicall

Function Documentation

def jabberbot.xmlrpcbot._xmlrpc_decorator (   function) [private]
A decorator function, which adds some maintenance code

This function takes care of preparing a MultiCall object and
an authentication token, and deleting them at the end.

Definition at line 23 of file xmlrpcbot.py.

00023 
00024 def _xmlrpc_decorator(function):
00025     """A decorator function, which adds some maintenance code
00026 
00027     This function takes care of preparing a MultiCall object and
00028     an authentication token, and deleting them at the end.
00029 
00030     """
00031     def wrapped_func(self, command):
00032         # Dummy function, so that the string appears in a .po file
00033         _ = lambda x: x
00034 
00035         self.token = None
00036         self.multicall = xmlrpclib.MultiCall(self.connection)
00037         jid = command.jid
00038         if type(jid) is not list:
00039             jid = [jid]
00040 
00041         try:
00042             try:
00043                 self.get_auth_token(command.jid)
00044                 if self.token:
00045                     self.multicall.applyAuthToken(self.token)
00046 
00047                 function(self, command)
00048                 self.commands_out.put_nowait(command)
00049 
00050             except xmlrpclib.Fault, fault:
00051                 msg = _("Your request has failed. The reason is:\n%(error)s")
00052                 self.log.error(str(fault))
00053                 self.report_error(jid, msg, {'error': fault.faultString})
00054             except xmlrpclib.Error, err:
00055                 msg = _("A serious error occured while processing your request:\n%(error)s")
00056                 self.log.error(str(err))
00057                 self.report_error(jid, msg, {'error': str(err)})
00058             except Exception, exc:
00059                 msg = _("An internal error has occured, please contact the administrator.")
00060                 self.log.critical(str(exc))
00061                 self.report_error(jid, msg)
00062 
00063         finally:
00064             del self.token
00065             del self.multicall
00066 
00067     return wrapped_func


Variable Documentation

Definition at line 35 of file xmlrpcbot.py.

Definition at line 34 of file xmlrpcbot.py.