Leafs are singletons, bound to the client object.
This commit is contained in:
parent
d0cba75ee0
commit
b466bf8ed2
|
@ -177,13 +177,14 @@ class User(Hackers):
|
||||||
kind = "uid"
|
kind = "uid"
|
||||||
_instances = dict()
|
_instances = dict()
|
||||||
|
|
||||||
def __new__(cls, name, *args, **kwargs):
|
def __new__(cls, name, client, *args, **kwargs):
|
||||||
if name not in cls._instances:
|
_name = f"{name}-{id(client)}"
|
||||||
cls._instances[name] = object.__new__(cls)
|
if _name not in cls._instances:
|
||||||
return cls._instances[name]
|
cls._instances[_name] = object.__new__(cls)
|
||||||
|
return cls._instances[_name]
|
||||||
|
|
||||||
def __init__(self, name, *args, **kwargs):
|
def __init__(self, name, client, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(client, *args, **kwargs)
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
@ -209,6 +210,13 @@ class Service(Robots):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
kind = "uid"
|
kind = "uid"
|
||||||
|
_instances = dict()
|
||||||
|
|
||||||
|
def __new__(cls, name, client, *args, **kwargs):
|
||||||
|
_name = f"{name}-{id(client)}"
|
||||||
|
if _name not in cls._instances:
|
||||||
|
cls._instances[_name] = object.__new__(cls)
|
||||||
|
return cls._instances[_name]
|
||||||
|
|
||||||
def __init__(self, name, *args, **kwargs):
|
def __init__(self, name, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -235,7 +243,14 @@ class Group(Congregations):
|
||||||
and may have Users and Services belonging to them.
|
and may have Users and Services belonging to them.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
kind = "uid"
|
kind = "cn"
|
||||||
|
_instances = dict()
|
||||||
|
|
||||||
|
def __new__(cls, name, client, *args, **kwargs):
|
||||||
|
_name = f"{name}-{id(client)}"
|
||||||
|
if _name not in cls._instances:
|
||||||
|
cls._instances[_name] = object.__new__(cls)
|
||||||
|
return cls._instances[_name]
|
||||||
|
|
||||||
def __init__(self, name, *args, **kwargs):
|
def __init__(self, name, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user