diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-06-26 06:43:47 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-06-26 06:43:47 +0000 |
commit | ec09b90690ab19219f11bbae9a2397d0133e3322 (patch) | |
tree | 6ae9d5a902d7167cf6d8dd75b6b50e55a4bdac8a | |
parent | 8fcfe5cdfb8d4dec3a5dd3f12df562b624321c48 (diff) | |
download | portage-ec09b90690ab19219f11bbae9a2397d0133e3322.tar.gz portage-ec09b90690ab19219f11bbae9a2397d0133e3322.tar.bz2 portage-ec09b90690ab19219f11bbae9a2397d0133e3322.zip |
Also use a separate proxy type for portage.mtimedb since it's independent
from the portdb and settings.
svn path=/main/trunk/; revision=10800
-rw-r--r-- | pym/portage/__init__.py | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index bcb2b7afb..516be638d 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -6930,11 +6930,31 @@ class _PortdbProxy(portage.util.ObjectProxy): 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 @@ class _PortdbProxy(portage.util.ObjectProxy): # 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 @@ def init_legacy_globals(): root = settings["ROOT"] - mtimedbfile = os.path.join("/", CACHE_PATH.lstrip(os.path.sep), "mtimedb") - mtimedb = MtimeDB(mtimedbfile) # ======================================================================== # COMPATIBILITY @@ -7007,9 +7023,18 @@ def init_legacy_globals(): # 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) |