Minor fixes

develop
blallo 2022-01-25 23:46:45 +01:00
parent e6cee09429
commit 077c53c5be
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
2 changed files with 6 additions and 3 deletions

View File

@ -4,10 +4,8 @@ from bonsai.ldapvaluelist import LDAPValueList
import bonsai.errors
from phi.exceptions import (
PhiAttributeMissing,
PhiEntryDoesNotExist,
PhiEntryExists,
PhiUnauthorized,
PhiUnexpectedRuntimeValue,
PhiCannotExecute,
)
@ -48,6 +46,8 @@ class Singleton(object):
name = f"{cls.__name__}-{args[0]}-{id(client)}"
else:
name = f"{cls.__name__}-{id(client)}"
if not hasattr(cls, "_instances"):
cls._instances = dict()
if name not in cls._instances:
cls._instances[name] = object.__new__(cls)
return cls._instances[name]

View File

@ -4,6 +4,9 @@ from bonsai import LDAPEntry
from multidict import MultiDict
from phi.async_ldap import mixins
from phi.exceptions import (
PhiUnexpectedRuntimeValue,
)
def parse_dn(dn):
@ -60,7 +63,7 @@ class Service(mixins.Member, mixins.Entry, mixins.Singleton):
ldap_attributes = ["uid", "ou", "userPassword"]
async def iter_groups(self): # To be monkeypatched later
pass # pragma: no cover
raise NotImplemented
async def groups(self):
return [g async for g in self.iter_groups()]