Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r10799 - main/trunk/pym/portage
Date: Thu, 26 Jun 2008 06:01:36
Message-Id: E1KBkXy-0007C9-VG@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-06-26 06:01:30 +0000 (Thu, 26 Jun 2008)
3 New Revision: 10799
4
5 Modified:
6 main/trunk/pym/portage/__init__.py
7 Log:
8 Use a separate proxy type to trigger portage.portdb initialization separately
9 from the rest of the legacy global variables. This can be useful since
10 sometimes the other variables are needed while the portdb is not.
11
12
13 Modified: main/trunk/pym/portage/__init__.py
14 ===================================================================
15 --- main/trunk/pym/portage/__init__.py 2008-06-26 05:28:04 UTC (rev 10798)
16 +++ main/trunk/pym/portage/__init__.py 2008-06-26 06:01:30 UTC (rev 10799)
17 @@ -6921,6 +6921,20 @@
18 name = object.__getattribute__(self, '_name')
19 return globals()[name]
20
21 +class _PortdbProxy(portage.util.ObjectProxy):
22 + """
23 + The portdb is initialized separately from the rest
24 + of the variables, since sometimes the other variables
25 + are needed while the portdb is not.
26 + """
27 +
28 + def _get_target(self):
29 + init_legacy_globals()
30 + global db, portdb, root
31 + if portdb is self:
32 + portdb = db[root]["porttree"].dbapi
33 + return portdb
34 +
35 # Initialization of legacy globals. No functions/classes below this point
36 # please! When the above functions and classes become independent of the
37 # below global variables, it will be possible to make the below code
38 @@ -6954,12 +6968,10 @@
39 del _initializing_globals
40
41 settings = db["/"]["vartree"].settings
42 - portdb = db["/"]["porttree"].dbapi
43
44 for myroot in db:
45 if myroot != "/":
46 settings = db[myroot]["vartree"].settings
47 - portdb = db[myroot]["porttree"].dbapi
48 break
49
50 root = settings["ROOT"]
51 @@ -6995,7 +7007,8 @@
52 # use within Portage. External use of this variable is unsupported because
53 # it is experimental and it's behavior is likely to change.
54 if "PORTAGE_LEGACY_GLOBALS" not in os.environ:
55 - for k in ("db", "settings", "root", "portdb", "selinux_enabled",
56 + portdb = _PortdbProxy()
57 + for k in ("db", "settings", "root", "selinux_enabled",
58 "mtimedbfile", "mtimedb", "archlist", "features", "groups",
59 "pkglines", "thirdpartymirrors", "usedefaults", "profiledir",
60 "flushmtimedb"):
61
62 --
63 gentoo-commits@l.g.o mailing list