ac7d03
From 4fe9684ccd97f0c6cd32d858f681f98fb97162dc Mon Sep 17 00:00:00 2001
ac7d03
From: Stanislav Laznicka <slaznick@redhat.com>
ac7d03
Date: Fri, 28 Apr 2017 09:31:45 +0200
ac7d03
Subject: [PATCH] Remove the cachedproperty class
ac7d03
ac7d03
The cachedproperty class was used in one special use-case where it only
ac7d03
caused issues. Let's get rid of it.
ac7d03
ac7d03
https://pagure.io/freeipa/issue/6878
ac7d03
ac7d03
Reviewed-By: Martin Basti <mbasti@redhat.com>
ac7d03
Reviewed-By: Christian Heimes <cheimes@redhat.com>
ac7d03
---
ac7d03
 ipalib/util.py | 34 ----------------------------------
ac7d03
 1 file changed, 34 deletions(-)
ac7d03
ac7d03
diff --git a/ipalib/util.py b/ipalib/util.py
ac7d03
index e9d4105775a2c9096b1718a604d31034b44bf0bd..8973a19abf56d1d1c5ba04f6edb4228dd2329e65 100644
ac7d03
--- a/ipalib/util.py
ac7d03
+++ b/ipalib/util.py
ac7d03
@@ -34,7 +34,6 @@ import dns
ac7d03
 import encodings
ac7d03
 import sys
ac7d03
 import ssl
ac7d03
-from weakref import WeakKeyDictionary
ac7d03
 
ac7d03
 import netaddr
ac7d03
 from dns import resolver, rdatatype
ac7d03
@@ -492,39 +491,6 @@ def remove_sshpubkey_from_output_list_post(context, entries):
ac7d03
         delattr(context, 'ipasshpubkey_added')
ac7d03
 
ac7d03
 
ac7d03
-class cachedproperty(object):
ac7d03
-    """
ac7d03
-    A property-like attribute that caches the return value of a method call.
ac7d03
-
ac7d03
-    When the attribute is first read, the method is called and its return
ac7d03
-    value is saved and returned. On subsequent reads, the saved value is
ac7d03
-    returned.
ac7d03
-
ac7d03
-    Typical usage:
ac7d03
-    class C(object):
ac7d03
-        @cachedproperty
ac7d03
-        def attr(self):
ac7d03
-            return 'value'
ac7d03
-    """
ac7d03
-    __slots__ = ('getter', 'store')
ac7d03
-
ac7d03
-    def __init__(self, getter):
ac7d03
-        self.getter = getter
ac7d03
-        self.store = WeakKeyDictionary()
ac7d03
-
ac7d03
-    def __get__(self, obj, cls):
ac7d03
-        if obj is None:
ac7d03
-            return None
ac7d03
-        if obj not in self.store:
ac7d03
-            self.store[obj] = self.getter(obj)
ac7d03
-        return self.store[obj]
ac7d03
-
ac7d03
-    def __set__(self, obj, value):
ac7d03
-        raise AttributeError("can't set attribute")
ac7d03
-
ac7d03
-    def __delete__(self, obj):
ac7d03
-        raise AttributeError("can't delete attribute")
ac7d03
-
ac7d03
 # regexp matching signed floating point number (group 1) followed by
ac7d03
 # optional whitespace followed by time unit, e.g. day, hour (group 7)
ac7d03
 time_duration_re = re.compile(r'([-+]?((\d+)|(\d+\.\d+)|(\.\d+)|(\d+\.)))\s*([a-z]+)', re.IGNORECASE)
ac7d03
-- 
ac7d03
2.12.2
ac7d03