1 |
Author: zmedico |
2 |
Date: 2008-07-03 09:05:38 +0000 (Thu, 03 Jul 2008) |
3 |
New Revision: 10909 |
4 |
|
5 |
Modified: |
6 |
main/trunk/bin/repoman |
7 |
main/trunk/pym/_emerge/__init__.py |
8 |
main/trunk/pym/portage/__init__.py |
9 |
Log: |
10 |
Add a portage._disable_legacy_globals() function. This deletes the |
11 |
ObjectProxy instances that are used for lazy initialization of legacy |
12 |
global variables. The purpose of deleting them is to prevent new code |
13 |
from referencing these deprecated variables. This allows the removal |
14 |
of the PORTAGE_LEGACY_GLOBALS variable which used to serve the same |
15 |
purpose. |
16 |
|
17 |
|
18 |
Modified: main/trunk/bin/repoman |
19 |
=================================================================== |
20 |
--- main/trunk/bin/repoman 2008-07-03 08:44:29 UTC (rev 10908) |
21 |
+++ main/trunk/bin/repoman 2008-07-03 09:05:38 UTC (rev 10909) |
22 |
@@ -38,14 +38,13 @@ |
23 |
if not hasattr(__builtins__, "set"): |
24 |
from sets import Set as set |
25 |
|
26 |
-os.environ["PORTAGE_LEGACY_GLOBALS"] = "false" |
27 |
try: |
28 |
import portage |
29 |
except ImportError: |
30 |
from os import path as osp |
31 |
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) |
32 |
import portage |
33 |
-del os.environ["PORTAGE_LEGACY_GLOBALS"] |
34 |
+portage._disable_legacy_globals() |
35 |
|
36 |
try: |
37 |
from repoman.checks import run_checks |
38 |
|
39 |
Modified: main/trunk/pym/_emerge/__init__.py |
40 |
=================================================================== |
41 |
--- main/trunk/pym/_emerge/__init__.py 2008-07-03 08:44:29 UTC (rev 10908) |
42 |
+++ main/trunk/pym/_emerge/__init__.py 2008-07-03 09:05:38 UTC (rev 10909) |
43 |
@@ -31,14 +31,13 @@ |
44 |
import os, stat |
45 |
import platform |
46 |
|
47 |
-os.environ["PORTAGE_LEGACY_GLOBALS"] = "false" |
48 |
try: |
49 |
import portage |
50 |
except ImportError: |
51 |
from os import path as osp |
52 |
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) |
53 |
import portage |
54 |
-del os.environ["PORTAGE_LEGACY_GLOBALS"] |
55 |
+portage._disable_legacy_globals() |
56 |
from portage import digraph, portdbapi |
57 |
from portage.const import NEWS_LIB_PATH, CACHE_PATH, PRIVATE_PATH, USER_CONFIG_PATH, GLOBAL_CONFIG_PATH |
58 |
|
59 |
|
60 |
Modified: main/trunk/pym/portage/__init__.py |
61 |
=================================================================== |
62 |
--- main/trunk/pym/portage/__init__.py 2008-07-03 08:44:29 UTC (rev 10908) |
63 |
+++ main/trunk/pym/portage/__init__.py 2008-07-03 09:05:38 UTC (rev 10909) |
64 |
@@ -7009,6 +7009,22 @@ |
65 |
name = object.__getattribute__(self, '_name') |
66 |
return globals()[name] |
67 |
|
68 |
+_legacy_global_var_names = ("archlist", "db", "features", |
69 |
+ "groups", "mtimedb", "mtimedbfile", "pkglines", |
70 |
+ "portdb", "profiledir", "root", "selinux_enabled", |
71 |
+ "settings", "thirdpartymirrors", "usedefaults") |
72 |
+ |
73 |
+def _disable_legacy_globals(): |
74 |
+ """ |
75 |
+ This deletes the ObjectProxy instances that are used |
76 |
+ for lazy initialization of legacy global variables. |
77 |
+ The purpose of deleting them is to prevent new code |
78 |
+ from referencing these deprecated variables. |
79 |
+ """ |
80 |
+ global _legacy_global_var_names |
81 |
+ for k in _legacy_global_var_names: |
82 |
+ globals().pop(k, None) |
83 |
+ |
84 |
# Initialization of legacy globals. No functions/classes below this point |
85 |
# please! When the above functions and classes become independent of the |
86 |
# below global variables, it will be possible to make the below code |
87 |
@@ -7072,11 +7088,7 @@ |
88 |
# within Portage under any circumstances. |
89 |
# ======================================================================== |
90 |
|
91 |
-# WARNING! |
92 |
-# The PORTAGE_LEGACY_GLOBALS environment variable is reserved for internal |
93 |
-# use within Portage. External use of this variable is unsupported because |
94 |
-# it is experimental and it's behavior is likely to change. |
95 |
-if "PORTAGE_LEGACY_GLOBALS" not in os.environ: |
96 |
+if True: |
97 |
|
98 |
_mtimedb_initialized = False |
99 |
mtimedb = _MtimedbProxy("mtimedb") |
100 |
|
101 |
-- |
102 |
gentoo-commits@l.g.o mailing list |