Add a RPCServer.deregister method

Deregister RPC exports when disabling a Core plugin
This commit is contained in:
Andrew Resch 2011-06-06 13:55:51 -07:00
parent 2542ad9234
commit 24c945f139
2 changed files with 14 additions and 0 deletions

View File

@ -424,6 +424,17 @@ class RPCServer(component.Component):
log.debug("Registering method: %s", name + "." + d) log.debug("Registering method: %s", name + "." + d)
self.factory.methods[name + "." + d] = getattr(obj, d) self.factory.methods[name + "." + d] = getattr(obj, d)
def deregister_object(self, obj):
"""
Deregisters an objects exported rpc methods.
:param obj: the object that was previously registered
"""
for key, value in self.factory.methods.items():
if value.im_self == obj:
del self.factory.methods[key]
def get_object_method(self, name): def get_object_method(self, name):
""" """
Returns a registered method. Returns a registered method.

View File

@ -58,6 +58,9 @@ class CorePluginBase(PluginBase):
component.get("RPCServer").register_object(self, plugin_name.lower()) component.get("RPCServer").register_object(self, plugin_name.lower())
log.debug("CorePlugin initialized..") log.debug("CorePlugin initialized..")
def __del__(self):
component.get("RPCServer").deregister_object(self)
class GtkPluginBase(PluginBase): class GtkPluginBase(PluginBase):
def __init__(self, plugin_name): def __init__(self, plugin_name):
super(GtkPluginBase, self).__init__("GtkPlugin." + plugin_name) super(GtkPluginBase, self).__init__("GtkPlugin." + plugin_name)