* Make dblink instantiate the ConfigProtect object on demand instead of
authorZac Medico <zmedico@gentoo.org>
Tue, 24 Aug 2010 17:10:36 +0000 (10:10 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 24 Aug 2010 17:10:36 +0000 (10:10 -0700)
  in the constructor, since it triggers lots of stat calls and it's
  wasteful for iter_owners.
* Fix dblink ConfigProtect construction to use EROOT.

pym/portage/dbapi/vartree.py

index b2e03e9c3fce682b45eaa86c6e5357935532d514..34dc147181044de6f70821d758ac573c6eba723d 100644 (file)
@@ -1958,12 +1958,6 @@ class dblink(object):
                self._verbose = self.settings.get("PORTAGE_VERBOSE") == "1"
 
                self.myroot=myroot
-               protect_obj = ConfigProtect(myroot,
-                       portage.util.shlex_split(mysettings.get("CONFIG_PROTECT", "")),
-                       portage.util.shlex_split(
-                       mysettings.get("CONFIG_PROTECT_MASK", "")))
-               self.updateprotect = protect_obj.updateprotect
-               self.isprotected = protect_obj.isprotected
                self._installed_instance = None
                self.contentscache = None
                self._contents_inodes = None
@@ -1971,6 +1965,7 @@ class dblink(object):
                self._linkmap_broken = False
                self._md5_merge_map = {}
                self._hash_key = (self.myroot, self.mycpv)
+               self._protect_obj = None
 
        def __hash__(self):
                return hash(self._hash_key)
@@ -1979,6 +1974,23 @@ class dblink(object):
                return isinstance(other, dblink) and \
                        self._hash_key == other._hash_key
 
+       def _get_protect_obj(self):
+
+               if self._protect_obj is None:
+                       self._protect_obj = ConfigProtect(self._eroot,
+                       portage.util.shlex_split(
+                               self.settings.get("CONFIG_PROTECT", "")),
+                       portage.util.shlex_split(
+                               self.settings.get("CONFIG_PROTECT_MASK", "")))
+
+               return self._protect_obj
+
+       def isprotected(self, obj):
+               return self._get_protect_obj().isprotected(obj)
+
+       def updateprotect(self):
+               self._get_protect_obj().updateprotect()
+
        def lockdb(self):
                if self._lock_vdb:
                        raise AssertionError("Lock already held.")