Replace several strings left over in reused sourcecode and warn when using unimplemented context callbacks

This commit is contained in:
Stefan Hacker
2010-12-27 17:35:45 +01:00
parent 54eaba49d8
commit 79cae2a2d5
2 changed files with 10 additions and 13 deletions

19
mumo.py
View File

@@ -104,7 +104,7 @@ def do_main_program():
def initializeIceConnection(self): def initializeIceConnection(self):
""" """
Establishes the two-way Ice connection and adds the authenticator to the Establishes the two-way Ice connection and adds MuMo to the
configured servers configured servers
""" """
ice = self.communicator() ice = self.communicator()
@@ -135,7 +135,7 @@ def do_main_program():
def attachCallbacks(self): def attachCallbacks(self):
""" """
Attaches all callbacks for meta and authenticators Attaches all callbacks
""" """
# Ice.ConnectionRefusedException # Ice.ConnectionRefusedException
@@ -152,10 +152,6 @@ def do_main_program():
servercb = Murmur.ServerCallbackPrx.uncheckedCast(servercbprx) servercb = Murmur.ServerCallbackPrx.uncheckedCast(servercbprx)
server.addCallback(servercb) server.addCallback(servercb)
# contextcbprx = self.adapter.addWithUUID(contextCallback(self.manager, sid))
# contextcb = Murmur.ServerCallbackPrx.uncheckedCast(contextcbprx)
# server.addContextCallback(contextcb)
except (Murmur.InvalidSecretException, Ice.UnknownUserException, Ice.ConnectionRefusedException), e: except (Murmur.InvalidSecretException, Ice.UnknownUserException, Ice.ConnectionRefusedException), e:
if isinstance(e, Ice.ConnectionRefusedException): if isinstance(e, Ice.ConnectionRefusedException):
error('Server refused connection') error('Server refused connection')
@@ -226,7 +222,7 @@ def do_main_program():
def fortifyIceFu(retval=None, exceptions=(Ice.Exception,)): def fortifyIceFu(retval=None, exceptions=(Ice.Exception,)):
""" """
Decorator that catches exceptions,logs them and returns a safe retval Decorator that catches exceptions,logs them and returns a safe retval
value. This helps preventing the authenticator getting stuck in value. This helps to prevent getting stuck in
critical code paths. Only exceptions that are instances of classes critical code paths. Only exceptions that are instances of classes
given in the exceptions list are not caught. given in the exceptions list are not caught.
@@ -262,19 +258,16 @@ def do_main_program():
def started(self, server, current=None): def started(self, server, current=None):
""" """
This function is called when a virtual server is started This function is called when a virtual server is started
and makes sure an authenticator gets attached if needed. and makes sure the callbacks get attached if needed.
""" """
sid = server.id() sid = server.id()
if not cfg.murmur.servers or sid in cfg.murmur.servers: if not cfg.murmur.servers or sid in cfg.murmur.servers:
info('Setting authenticator for virtual server %d', server.id()) info('Setting callbacks for virtual server %d', server.id())
try: try:
servercbprx = self.app.adapter.addWithUUID(serverCallback(self.app.manager, server, sid)) servercbprx = self.app.adapter.addWithUUID(serverCallback(self.app.manager, server, sid))
servercb = Murmur.ServerCallbackPrx.uncheckedCast(servercbprx) servercb = Murmur.ServerCallbackPrx.uncheckedCast(servercbprx)
server.addCallback(servercb) server.addCallback(servercb)
# contextcbprx = self.adapter.addWithUUID(contextCallback(self.app.manager, sid))
# contextcb = Murmur.ServerCallbackPrx.uncheckedCast(contextcbprx)
# server.addContextCallback(contextcb)
# Apparently this server was restarted without us noticing # Apparently this server was restarted without us noticing
except (Murmur.InvalidSecretException, Ice.UnknownUserException), e: except (Murmur.InvalidSecretException, Ice.UnknownUserException), e:
if hasattr(e, "unknown") and e.unknown != "Murmur::InvalidSecretException": if hasattr(e, "unknown") and e.unknown != "Murmur::InvalidSecretException":
@@ -470,7 +463,7 @@ if __name__ == '__main__':
except ImportError: except ImportError:
if option.force_daemon: if option.force_daemon:
print >> sys.stderr, 'Fatal error, could not daemonize process due to missing "daemon" library, ' \ print >> sys.stderr, 'Fatal error, could not daemonize process due to missing "daemon" library, ' \
'please install the missing dependency and restart the authenticator' 'please install the missing dependency and restart the application'
sys.exit(1) sys.exit(1)
ret = do_main_program() ret = do_main_program()
else: else:

View File

@@ -356,6 +356,10 @@ class MumoManager(Worker):
@param queue Target worker queue @param queue Target worker queue
@see MumoManagerRemote @see MumoManagerRemote
""" """
#TODO: Implement context callbacks
self.log().error("Context callbacks not implemented at this point")
return self.__add_to_dict(self.contextCallbacks, queue, handler, servers) return self.__add_to_dict(self.contextCallbacks, queue, handler, servers)
@local_thread @local_thread