From e9c9e3f009347d356f4d59701321888e7f00fb94 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Mon, 22 Jun 2015 11:28:09 +0000 Subject: ipaplatform: Do not use MagicDict for KnownServices https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky --- ipaplatform/base/services.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'ipaplatform') diff --git a/ipaplatform/base/services.py b/ipaplatform/base/services.py index 11fa27357..56e959e91 100644 --- a/ipaplatform/base/services.py +++ b/ipaplatform/base/services.py @@ -26,11 +26,11 @@ interacting with system services. import os import json import time +import collections import ipalib from ipapython import ipautil from ipaplatform.paths import paths -from ipalib.plugable import MagicDict # Canonical names of services as IPA wants to see them. As we need to have # *some* naming, set them as in Red Hat distributions. Actual implementation @@ -57,7 +57,7 @@ wellknownports = { SERVICE_POLL_INTERVAL = 0.1 # seconds -class KnownServices(MagicDict): +class KnownServices(collections.Mapping): """ KnownServices is an abstract class factory that should give out instances of well-known platform services. Actual implementation must create these @@ -65,6 +65,27 @@ class KnownServices(MagicDict): and cache them. """ + def __init__(self, d): + self.__d = d + + def __getitem__(self, key): + return self.__d[key] + + def __iter__(self): + return iter(self.__d) + + def __len__(self): + return len(self.__d) + + def __call__(self): + return self.__d.itervalues() + + def __getattr__(self, name): + try: + return self.__d[name] + except KeyError: + raise AttributeError(name) + class PlatformService(object): """ -- cgit