public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r10799 - main/trunk/pym/portage
@ 2008-06-26  6:01 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-06-26  6:01 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2008-06-26 06:01:30 +0000 (Thu, 26 Jun 2008)
New Revision: 10799

Modified:
   main/trunk/pym/portage/__init__.py
Log:
Use a separate proxy type to trigger portage.portdb initialization separately
from the rest of the legacy global variables. This can be useful since
sometimes the other variables are needed while the portdb is not.


Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py	2008-06-26 05:28:04 UTC (rev 10798)
+++ main/trunk/pym/portage/__init__.py	2008-06-26 06:01:30 UTC (rev 10799)
@@ -6921,6 +6921,20 @@
 		name = object.__getattribute__(self, '_name')
 		return globals()[name]
 
+class _PortdbProxy(portage.util.ObjectProxy):
+	"""
+	The portdb is initialized separately from the rest
+	of the variables, since sometimes the other variables
+	are needed while the portdb is not.
+	"""
+
+	def _get_target(self):
+		init_legacy_globals()
+		global db, portdb, root
+		if portdb is self:
+			portdb = db[root]["porttree"].dbapi
+		return portdb
+
 # Initialization of legacy globals.  No functions/classes below this point
 # please!  When the above functions and classes become independent of the
 # below global variables, it will be possible to make the below code
@@ -6954,12 +6968,10 @@
 	del _initializing_globals
 
 	settings = db["/"]["vartree"].settings
-	portdb = db["/"]["porttree"].dbapi
 
 	for myroot in db:
 		if myroot != "/":
 			settings = db[myroot]["vartree"].settings
-			portdb = db[myroot]["porttree"].dbapi
 			break
 
 	root = settings["ROOT"]
@@ -6995,7 +7007,8 @@
 # use within Portage.  External use of this variable is unsupported because
 # it is experimental and it's behavior is likely to change.
 if "PORTAGE_LEGACY_GLOBALS" not in os.environ:
-	for k in ("db", "settings", "root", "portdb", "selinux_enabled",
+	portdb = _PortdbProxy()
+	for k in ("db", "settings", "root", "selinux_enabled",
 		"mtimedbfile", "mtimedb", "archlist", "features", "groups",
 		"pkglines", "thirdpartymirrors", "usedefaults", "profiledir",
 		"flushmtimedb"):

-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-06-26  6:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-26  6:01 [gentoo-commits] portage r10799 - main/trunk/pym/portage Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox