Commit b6d81a29 authored by Devaev Maxim's avatar Devaev Maxim

API for removing shared objects

parent 23d6012b
import sys
sys.path.append("..") # path hook
import settingsd.service
import settingsd.shared
class Hello(settingsd.service.FunctionObject) :
......@@ -16,6 +17,11 @@ class Hello(settingsd.service.FunctionObject) :
def dump(self) :
return str(self)
@settingsd.service.customMethod("org.liksys.settingsd")
def die(self) :
settingsd.shared.Functions.Hello.removeFromConnection()
settingsd.shared.Functions.removeSharedObject("Hello")
class Requisites(settingsd.service.Requisites) :
@classmethod
def serviceName(self) :
......
......@@ -34,7 +34,6 @@ class Service(object) :
def init(self) :
pass
@abc.abstractmethod
def close(self) :
pass
......@@ -49,6 +48,12 @@ class CustomObject(dbus.service.Object) :
def objectPath(self) :
self._object_path
def addToConnection(self, connection = None, path = None) :
self.add_to_connection(connection, path)
def removeFromConnection(self, conneciton = None, path = None) :
self.remove_from_connection(conneciton, path)
class FunctionObject(CustomObject) :
def __init__(self, object_path) :
CustomObject.__init__(self, dbus_tools.joinPath(config.value("service", "path"), "functions", object_path))
......
......@@ -5,6 +5,9 @@
class SharedConflict(Exception) :
pass
class SharedNotExist(Exception) :
pass
#####
class SharedMeta(type) :
......@@ -19,8 +22,11 @@ class SharedMeta(type) :
setattr(cls, shared_object_name, shared_object)
def removeSharedObject(cls, shared_object_name) :
if cls._shared_objects_dict.has_key(shared_object_name) :
cls._shared_objects_dict.pop(shared_object_name)
if not cls._shared_objects_dict.has_key(shared_object_name) :
raise SharedNotExist("Shared \"%s\" does not exist in collection \"%s\"" % (shared_object_name, cls.__name__))
cls._shared_objects_dict.pop(shared_object_name)
delattr(cls, shared_object_name)
def hasSharedObject(cls, shared_object) :
return ( shared_object in cls._shared_objects_dict.keys() or shared_object in cls._shared_objects_dict.values() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment