Add a RPCServer.deregister method
Deregister RPC exports when disabling a Core plugin
This commit is contained in:
parent
2542ad9234
commit
24c945f139
|
@ -424,6 +424,17 @@ class RPCServer(component.Component):
|
|||
log.debug("Registering method: %s", name + "." + 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):
|
||||
"""
|
||||
Returns a registered method.
|
||||
|
|
|
@ -58,6 +58,9 @@ class CorePluginBase(PluginBase):
|
|||
component.get("RPCServer").register_object(self, plugin_name.lower())
|
||||
log.debug("CorePlugin initialized..")
|
||||
|
||||
def __del__(self):
|
||||
component.get("RPCServer").deregister_object(self)
|
||||
|
||||
class GtkPluginBase(PluginBase):
|
||||
def __init__(self, plugin_name):
|
||||
super(GtkPluginBase, self).__init__("GtkPlugin." + plugin_name)
|
||||
|
|
Loading…
Reference in New Issue