found = False
for room in self.rooms.itervalues():
for player in room.clients.itervalues():
if player.username.lower() == toUsername.lower():
player.sendRecievePrivMsg(fromUsername, message)
found = True
return found

#from Basic HTTP Authentication with XMLRPC in Python
class VerifyingXMLRPCServer(SimpleXMLRPCServer):
def __init__(self, *args, **kargs):
# we use an inner class so that we can call out to the
# authenticate method
class VerifyingRequestHandler(SimpleXMLRPCRequestHandler ):
# this is the method we must override
def parse_request(myself):
# first, call the original implementation which returns
# True if all OK so far
if SimpleXMLRPCRequestHandler.parse_request(myself):
# next we authenticate
if self.authenticate(myself.headers):
return True
else:
# if authentication fails, tell the client
myself.send_error(401, 'Authentication failed')
return False
# and intialise the superclass with the above
SimpleXMLRPCServer.__init__(self, requestHandler=VerifyingRequestHandler, *args, **kargs)