summaryrefslogtreecommitdiffstats
path: root/ipalib/__init__.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-12-22 23:09:35 -0700
committerJason Gerard DeRose <jderose@redhat.com>2008-12-22 23:09:35 -0700
commitfd43b39145382b96cd2e0d0da3d5dcbe0d3a4a2a (patch)
tree746f5a65638d3dfc7a72363532380e4a6b31cc6f /ipalib/__init__.py
parent01cae56e0a19876cf6a614469c0c5e6fb73170e6 (diff)
downloadfreeipa-fd43b39145382b96cd2e0d0da3d5dcbe0d3a4a2a.tar.gz
freeipa-fd43b39145382b96cd2e0d0da3d5dcbe0d3a4a2a.tar.xz
freeipa-fd43b39145382b96cd2e0d0da3d5dcbe0d3a4a2a.zip
Moved setting of run-time variables from Env.__init__() to Env._bootstrap()
Diffstat (limited to 'ipalib/__init__.py')
-rw-r--r--ipalib/__init__.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/ipalib/__init__.py b/ipalib/__init__.py
index b9a3c96d5..e30b7fed6 100644
--- a/ipalib/__init__.py
+++ b/ipalib/__init__.py
@@ -685,41 +685,40 @@ is configured.
Environment variables
---------------------
-Plugins access various environment variables and run-time information through
-``self.api.env`` (for convenience, ``self.env`` is equivalent).
+Plugins access configuration variables and run-time information through
+``self.api.env`` (or for convenience, ``self.env`` is equivalent). This
+attribute is a refences to the `ipalib.config.Env` instance created in
+`plugable.API.__init__()`.
-When you create a fresh `plugable.API` instance, its ``env`` attribute is
-likewise a freshly created `config.Env` instance, which will already be
-populated with certain run-time information. For example:
+After `API.bootstrap()` has been called, the `Env` instance will be populated
+with all the environment information used by the built-in plugins.
+This will be called before any plugins are registered, so plugin authors can
+assume these variables will all exist by the time the module containing their
+plugin (or plugins) is imported. For example:
>>> api = create_api()
->>> list(api.env)
-['bin', 'dot_ipa', 'home', 'ipalib', 'mode', 'script', 'site_packages']
-
-Here is a quick overview of the run-time information:
-
-============= ================================ =======================
-Key Source or example value Description
-============= ================================ =======================
-bin /usr/bin Dir. containing script
-dot_ipa ~/.ipa User config directory
-home os.environ['HOME'] User home dir.
-ipalib .../site-packages/ipalib Dir. of ipalib package
-mode 'production' or 'unit_test' The mode ipalib is in
-script sys.argv[0] Path of script
-site_packages /usr/lib/python2.5/site-packages Dir. containing ipalib/
-============= ================================ =======================
-
-After `plugable.API.bootstrap()` has been called, the env instance will be
-populated with all the environment information used by the built-in plugins.
-This will typically be called before any plugins are registered. For example:
-
>>> len(api.env)
-7
+1
>>> api.bootstrap(in_server=True) # We want to execute, not forward
>>> len(api.env)
35
+`Env._bootstrap()`, which is called by `API.bootstrap()`, will create several
+run-time variables that connot be overriden in configuration files or through
+command-line options. Here is an overview of this run-time information:
+
+============= ============================= =======================
+Key Example value Description
+============= ============================= =======================
+bin '/usr/bin' Dir. containing script
+dot_ipa '/home/jderose/.ipa' User config directory
+home os.environ['HOME'] User home dir.
+ipalib '.../site-packages/ipalib' Dir. of ipalib package
+mode 'unit_test' The mode ipalib is in
+script sys.argv[0] Path of script
+site_packages '.../python2.5/site-packages' Dir. containing ipalib/
+============= ============================= =======================
+
If your plugin requires new environment variables *and* will be included in
the freeIPA built-in plugins, you should add the defaults for your variables
in `ipalib.constants.DEFAULT_CONFIG`. Also, you should consider whether your