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

Author: zmedico
Date: 2008-06-26 06:43:47 +0000 (Thu, 26 Jun 2008)
New Revision: 10800

Modified:
   main/trunk/pym/portage/__init__.py
Log:
Also use a separate proxy type for portage.mtimedb since it's independent
from the portdb and settings.


Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py	2008-06-26 06:01:30 UTC (rev 10799)
+++ main/trunk/pym/portage/__init__.py	2008-06-26 06:43:47 UTC (rev 10800)
@@ -6930,11 +6930,31 @@
 
 	def _get_target(self):
 		init_legacy_globals()
-		global db, portdb, root
-		if portdb is self:
+		global db, portdb, root, _portdb_initialized
+		if not _portdb_initialized:
 			portdb = db[root]["porttree"].dbapi
+			_portdb_initialized = True
 		return portdb
 
+class _MtimedbProxy(portage.util.ObjectProxy):
+	"""
+	The mtimedb is independent from the portdb and other globals.
+	"""
+
+	def __init__(self, name):
+		portage.util.ObjectProxy.__init__(self)
+		object.__setattr__(self, '_name', name)
+
+	def _get_target(self):
+		global mtimedb, mtimedbfile, _mtimedb_initialized
+		if not _mtimedb_initialized:
+			mtimedbfile = os.path.join("/",
+				CACHE_PATH.lstrip(os.path.sep), "mtimedb")
+			mtimedb = MtimeDB(mtimedbfile)
+			_mtimedb_initialized = True
+		name = object.__getattribute__(self, '_name')
+		return globals()[name]
+
 # 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
@@ -6943,8 +6963,6 @@
 # code that is aware of this flag to import portage without the unnecessary
 # overhead (and other issues!) of initializing the legacy globals.
 
-_globals_initialized = False
-
 def init_legacy_globals():
 	global _globals_initialized
 	if _globals_initialized:
@@ -6976,8 +6994,6 @@
 
 	root = settings["ROOT"]
 
-	mtimedbfile = os.path.join("/", CACHE_PATH.lstrip(os.path.sep), "mtimedb")
-	mtimedb = MtimeDB(mtimedbfile)
 
 	# ========================================================================
 	# COMPATIBILITY
@@ -7007,9 +7023,18 @@
 # 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:
+
+	_mtimedb_initialized = False
+	mtimedb     = _MtimedbProxy("mtimedb")
+	mtimedbfile = _MtimedbProxy("mtimedbfile")
+
+	_portdb_initialized  = False
 	portdb = _PortdbProxy()
+
+	_globals_initialized = False
+
 	for k in ("db", "settings", "root", "selinux_enabled",
-		"mtimedbfile", "mtimedb", "archlist", "features", "groups",
+		"archlist", "features", "groups",
 		"pkglines", "thirdpartymirrors", "usedefaults", "profiledir",
 		"flushmtimedb"):
 		globals()[k] = _LegacyGlobalProxy(k)

-- 
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:43 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:43 [gentoo-commits] portage r10800 - 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