From f80beb948bb8914df922e85ef20d9152ca47b527 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 24 Oct 2008 15:07:07 -0600 Subject: Added ipalib/constants.py; added Env._load_config() method along with comprehensive unit tests for same --- ipalib/constants.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ipalib/constants.py (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py new file mode 100644 index 00000000..d817fda4 --- /dev/null +++ b/ipalib/constants.py @@ -0,0 +1,25 @@ +# Authors: +# Jason Gerard DeRose +# +# Copyright (C) 2008 Red Hat +# see file 'COPYING' for use and warranty information +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 only +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +""" +Constants centralized in one file. +""" + +# The section read in config files, i.e. [global] +CONFIG_SECTION = 'global' -- cgit From ac4efac3944d180cffd0ad9d63f631dc928e1d28 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 24 Oct 2008 20:02:14 -0600 Subject: Finished Env._finalize_core() and corresponding unit tests --- ipalib/constants.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index d817fda4..a1cc5b4c 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -21,5 +21,41 @@ Constants centralized in one file. """ -# The section read in config files, i.e. [global] +# The section to read in the config files, i.e. [global] CONFIG_SECTION = 'global' + + +# The default configuration for api.env +DEFAULT_CONFIG = ( + ('lite_xmlrpc_port', 8888), + ('lite_webui_port', 9999), + ('xmlrpc_uri', 'http://localhost:8888'), + ('ldap_uri', ''), + + ('verbose', False), + ('debug', False), + + # Env.__init__() or Env._bootstrap() or Env._finalize_core() + # will have filled in all the keys below by the time DEFAULT_CONFIG + # is merged in, so the values below are never actually used. They are + # listed both to provide a big picture and so DEFAULT_CONFIG contains + # the keys that should be present after Env._load_standard is called. + + # Set in Env.__init__(): + ('ipalib', None), # The directory containing ipalib/__init__.py + ('site_packages', None), # The directory contaning ipalib + ('script', None), # sys.argv[0] + ('bin', None), # The directory containing script + ('home', None), # The home directory of user underwhich process is running + ('dot_ipa', None), # ~/.ipa directory + + # Set in Env._bootstrap(): + ('in_tree', None), # Whether or not running in-tree (bool) + ('context', None), # Name of context, default is 'default' + ('conf', None), # Path to configuration file + + # Set in Env._finalize_core(): + ('in_server', None), # Whether or not running in-server (bool) + ('log', None), # Path to log file + +) -- cgit From ff5cb4cf6f036db892ebedc018b9740438c7e192 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 24 Oct 2008 20:59:11 -0600 Subject: Added more needed config in DEFAULT_CONFIG --- ipalib/constants.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index a1cc5b4c..e7b370f1 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -1,4 +1,5 @@ # Authors: +# Martin Nagy # Jason Gerard DeRose # # Copyright (C) 2008 Red Hat @@ -18,7 +19,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -Constants centralized in one file. +All constants centralized in one file. """ # The section to read in the config files, i.e. [global] @@ -26,20 +27,46 @@ CONFIG_SECTION = 'global' # The default configuration for api.env +# This is a tuple instead of a dict so that it is immutable. +# To create a dict with this config, just "d = dict(DEFAULT_CONFIG)". DEFAULT_CONFIG = ( + # Domain, realm, basedn: + ('domain', 'example.com'), + ('realm', 'EXAMPLE.COM'), + ('basedn', 'dc=example,dc=com'), + + # LDAP containers: + ('container_accounts', 'cn=accounts'), + ('container_user', 'cn=users,cn=accounts'), + ('container_group', 'cn=groups,cn=accounts'), + ('container_service', 'cn=services,cn=accounts'), + ('container_host', 'cn=computers,cn=accounts'), + + # Ports, hosts, and URIs: ('lite_xmlrpc_port', 8888), ('lite_webui_port', 9999), ('xmlrpc_uri', 'http://localhost:8888'), - ('ldap_uri', ''), + ('ldap_uri', 'ldap://localhost:389'), + ('ldap_host', 'localhost'), + ('ldap_port', 389), + # Debugging: ('verbose', False), ('debug', False), + + # ******************************************************** + # The remaining keys are never set from the values here! + # ******************************************************** + # # Env.__init__() or Env._bootstrap() or Env._finalize_core() # will have filled in all the keys below by the time DEFAULT_CONFIG # is merged in, so the values below are never actually used. They are - # listed both to provide a big picture and so DEFAULT_CONFIG contains - # the keys that should be present after Env._load_standard is called. + # listed both to provide a big picture and also so DEFAULT_CONFIG contains + # the keys that should be present after Env._finalize_core() is called. + # + # The values are all None so if for some reason any of these keys were + # set from the values here, an exception will be raised. # Set in Env.__init__(): ('ipalib', None), # The directory containing ipalib/__init__.py -- cgit From 28dd8e74bdefd62307881f6e086af59db97a21a0 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 27 Oct 2008 00:58:25 -0600 Subject: Env._bootstrap() now also sets Env.conf_default --- ipalib/constants.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index e7b370f1..4942cc9b 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -79,7 +79,8 @@ DEFAULT_CONFIG = ( # Set in Env._bootstrap(): ('in_tree', None), # Whether or not running in-tree (bool) ('context', None), # Name of context, default is 'default' - ('conf', None), # Path to configuration file + ('conf', None), # Path to config file + ('conf_default', None), # Path to common default config file # Set in Env._finalize_core(): ('in_server', None), # Whether or not running in-server (bool) -- cgit From 9b1e3f59465c6ba33f4266bc3add469b5e1711eb Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 27 Oct 2008 19:21:49 -0600 Subject: More docstrings, functionality, and unit tests for improved CLI class --- ipalib/constants.py | 1 - 1 file changed, 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 4942cc9b..9da93e00 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -54,7 +54,6 @@ DEFAULT_CONFIG = ( ('verbose', False), ('debug', False), - # ******************************************************** # The remaining keys are never set from the values here! # ******************************************************** -- cgit From 6e456cc7494bc00e905361f3e6d42dff99089c6b Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 27 Oct 2008 23:30:55 -0600 Subject: More CLI cleanup, got all basics working again --- ipalib/constants.py | 1 + 1 file changed, 1 insertion(+) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 9da93e00..25ee6c31 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -53,6 +53,7 @@ DEFAULT_CONFIG = ( # Debugging: ('verbose', False), ('debug', False), + ('mode', 'production'), # ******************************************************** # The remaining keys are never set from the values here! -- cgit From 316bd855d5720f4babfb79d20c391de3f8958a60 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 28 Oct 2008 01:39:02 -0600 Subject: Added util.configure_logging() function; API.bootstrap() now calls util.configure_logging() --- ipalib/constants.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 25ee6c31..7220561f 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -87,3 +87,19 @@ DEFAULT_CONFIG = ( ('log', None), # Path to log file ) + + +LOGGING_CONSOLE_FORMAT = ' '.join([ + '%(levelname)s', + '%(message)s', +]) + + +# Tab-delimited format designed to be easily opened in a spreadsheet: +LOGGING_FILE_FORMAT = ' '.join([ + '%(created)f', + '%(levelname)s', + '%(message)r', # Using %r for repr() so message is a single line + '%(pathname)s', + '%(lineno)d', +]) -- cgit From fbcb55bd11d17dbff8ec3c7c99cf7b3bb91d3752 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 28 Oct 2008 02:10:56 -0600 Subject: lite-xmlrpc.py now uses api.bootstrap() property, logs to api.logger --- ipalib/constants.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 7220561f..f4a440c6 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -89,7 +89,8 @@ DEFAULT_CONFIG = ( ) -LOGGING_CONSOLE_FORMAT = ' '.join([ +LOGGING_CONSOLE_FORMAT = ': '.join([ + '%(name)s', '%(levelname)s', '%(message)s', ]) -- cgit From 5269d1396c2e299d7fc66b55df7a84d482927549 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 31 Oct 2008 18:55:32 -0600 Subject: Logging formats are now env variables; added log_format_stderr_debug format used when env.debug is True --- ipalib/constants.py | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index f4a440c6..7b0e1661 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -22,10 +22,38 @@ All constants centralized in one file. """ + # The section to read in the config files, i.e. [global] CONFIG_SECTION = 'global' +# Log format for console output +LOG_FORMAT_STDERR = ': '.join([ + '%(name)s', + '%(levelname)s', + '%(message)s', +]) + + +# Log format for console output when env.dubug is True: +LOG_FORMAT_STDERR_DEBUG = ' '.join([ + '%(levelname)s', + '%(message)r', + '%(lineno)d', + '%(filename)s', +]) + + +# Tab-delimited log format for file (easy to opened in a spreadsheet): +LOG_FORMAT_FILE = ' '.join([ + '%(created)f', + '%(levelname)s', + '%(message)r', # Using %r for repr() so message is a single line + '%(lineno)d', + '%(pathname)s', +]) + + # The default configuration for api.env # This is a tuple instead of a dict so that it is immutable. # To create a dict with this config, just "d = dict(DEFAULT_CONFIG)". @@ -55,6 +83,11 @@ DEFAULT_CONFIG = ( ('debug', False), ('mode', 'production'), + # Logging: + ('log_format_stderr', LOG_FORMAT_STDERR), + ('log_format_stderr_debug', LOG_FORMAT_STDERR_DEBUG), + ('log_format_file', LOG_FORMAT_FILE), + # ******************************************************** # The remaining keys are never set from the values here! # ******************************************************** @@ -87,20 +120,3 @@ DEFAULT_CONFIG = ( ('log', None), # Path to log file ) - - -LOGGING_CONSOLE_FORMAT = ': '.join([ - '%(name)s', - '%(levelname)s', - '%(message)s', -]) - - -# Tab-delimited format designed to be easily opened in a spreadsheet: -LOGGING_FILE_FORMAT = ' '.join([ - '%(created)f', - '%(levelname)s', - '%(message)r', # Using %r for repr() so message is a single line - '%(pathname)s', - '%(lineno)d', -]) -- cgit From 242a8183a7cc002f496421352e8346db4232648b Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 31 Oct 2008 20:25:33 -0600 Subject: Added custom log formatter util.LogFormatter that makes the human-readable time stamp in UTC --- ipalib/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 7b0e1661..99b0ea71 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -45,8 +45,8 @@ LOG_FORMAT_STDERR_DEBUG = ' '.join([ # Tab-delimited log format for file (easy to opened in a spreadsheet): -LOG_FORMAT_FILE = ' '.join([ - '%(created)f', +LOG_FORMAT_FILE = '\t'.join([ + '%(asctime)s', '%(levelname)s', '%(message)r', # Using %r for repr() so message is a single line '%(lineno)d', -- cgit From e825bc7ccbc787e65efa7171e9f19793bcd88615 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Tue, 4 Nov 2008 14:03:43 -0500 Subject: Revive the hostgroup_container and include add/remove hosts in hostgroups plugin --- ipalib/constants.py | 1 + 1 file changed, 1 insertion(+) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 99b0ea71..9bd82a1b 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -69,6 +69,7 @@ DEFAULT_CONFIG = ( ('container_group', 'cn=groups,cn=accounts'), ('container_service', 'cn=services,cn=accounts'), ('container_host', 'cn=computers,cn=accounts'), + ('container_hostgroup', 'cn=hostgroups,cn=accounts'), # Ports, hosts, and URIs: ('lite_xmlrpc_port', 8888), -- cgit From 9aa14333a46d3a57c1fc9fad6068090eb029070f Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 10 Nov 2008 15:53:10 -0700 Subject: Added 'conf_dir' env variable, which is directory containing config files --- ipalib/constants.py | 1 + 1 file changed, 1 insertion(+) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 9bd82a1b..b8f93d21 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -115,6 +115,7 @@ DEFAULT_CONFIG = ( ('context', None), # Name of context, default is 'default' ('conf', None), # Path to config file ('conf_default', None), # Path to common default config file + ('conf_dir', None), # Directory containing config files # Set in Env._finalize_core(): ('in_server', None), # Whether or not running in-server (bool) -- cgit From 014af24731ff39520a9635694ed99dc9d09669c9 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 12 Nov 2008 00:46:04 -0700 Subject: Changed calling signature of output_for_cli(); started work on 'textui' backend plugin --- ipalib/constants.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index b8f93d21..6210e6c8 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -22,6 +22,8 @@ All constants centralized in one file. """ +# Used for a tab (or indentation level) when formatting for CLI: +CLI_TAB = ' ' # Two spaces # The section to read in the config files, i.e. [global] CONFIG_SECTION = 'global' -- cgit From c513743e7c9a611d0b3b0abaf13b79d6237ed6da Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 14 Nov 2008 18:04:57 -0500 Subject: Add autmount-specific location and default entries --- ipalib/constants.py | 1 + 1 file changed, 1 insertion(+) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 6210e6c8..7e562b53 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -72,6 +72,7 @@ DEFAULT_CONFIG = ( ('container_service', 'cn=services,cn=accounts'), ('container_host', 'cn=computers,cn=accounts'), ('container_hostgroup', 'cn=hostgroups,cn=accounts'), + ('container_automount', 'cn=automount'), # Ports, hosts, and URIs: ('lite_xmlrpc_port', 8888), -- cgit From 22209a0f0333526fe953a66f6ea4dd1be18dddc6 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 10 Dec 2008 21:14:05 -0700 Subject: Started roughing out the consolidated type/parameter system in parameters.py; started corresponding unit tests --- ipalib/constants.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 7e562b53..06ff99d5 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -19,9 +19,13 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -All constants centralized in one file. +All constants centralised in one file. """ +# The parameter system treats all these values as None: +NULLS = (None, '', u'', tuple(), []) + + # Used for a tab (or indentation level) when formatting for CLI: CLI_TAB = ' ' # Two spaces -- cgit From 5c47b56d14d56b825cbfe6a06e056bb98fbb2378 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 11 Dec 2008 18:07:54 -0700 Subject: Finished kwarg validation and extension mechanism in parameter.Param --- ipalib/constants.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 06ff99d5..d028a001 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -26,6 +26,12 @@ All constants centralised in one file. NULLS = (None, '', u'', tuple(), []) +TYPE_ERROR = '%s: need a %r; got %r (a %r)' + + +CALLABLE_ERROR = '%s: need a callable; got %r (a %r)' + + # Used for a tab (or indentation level) when formatting for CLI: CLI_TAB = ' ' # Two spaces -- cgit From cb2f294cfef9b47e03b82c85cf1db7e7bc3574ef Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 18 Dec 2008 01:57:39 -0700 Subject: New Param: added missing unit tests for TypeError and ValueError cases in parse_param_spec() --- ipalib/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index d028a001..ad1e3f7c 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -26,7 +26,7 @@ All constants centralised in one file. NULLS = (None, '', u'', tuple(), []) -TYPE_ERROR = '%s: need a %r; got %r (a %r)' +TYPE_ERROR = '%s: need a %r; got %r (which is a %r)' CALLABLE_ERROR = '%s: need a callable; got %r (a %r)' -- cgit From 4d1681176afc45c57fb4316892f939bda1bacf1d Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 18 Dec 2008 02:08:41 -0700 Subject: New Param: added unit tests for TypeError cases in DefaultFrom.__init__() --- ipalib/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index ad1e3f7c..ef2aef72 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -29,7 +29,7 @@ NULLS = (None, '', u'', tuple(), []) TYPE_ERROR = '%s: need a %r; got %r (which is a %r)' -CALLABLE_ERROR = '%s: need a callable; got %r (a %r)' +CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)' # Used for a tab (or indentation level) when formatting for CLI: -- cgit From dc54dee622bf9ff95a59530423ac5caa01868373 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 18 Dec 2008 14:01:59 -0700 Subject: Started work on per-request gettext setup --- ipalib/constants.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index ef2aef72..45c9f278 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -25,12 +25,14 @@ All constants centralised in one file. # The parameter system treats all these values as None: NULLS = (None, '', u'', tuple(), []) - +# Standard format for TypeError message: TYPE_ERROR = '%s: need a %r; got %r (which is a %r)' - +# Stardard format for TypeError message when a callable is expected: CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)' +# Standard format for StandardError message when overriding an attribute: +OVERRIDE_ERROR = 'cannot override %s existing value %r with %r' # Used for a tab (or indentation level) when formatting for CLI: CLI_TAB = ' ' # Two spaces -- cgit From 014cca57ad31f0ff9230923c8b7fdb1b59157dae Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 22 Dec 2008 16:16:57 -0700 Subject: The Env.__setitem__() implied conversion is now case sensitive; Env.__setitem__() now also accepts None as a value --- ipalib/constants.py | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index 45c9f278..ef7de44c 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -32,7 +32,7 @@ TYPE_ERROR = '%s: need a %r; got %r (which is a %r)' CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)' # Standard format for StandardError message when overriding an attribute: -OVERRIDE_ERROR = 'cannot override %s existing value %r with %r' +OVERRIDE_ERROR = 'cannot override %s value %r with %r' # Used for a tab (or indentation level) when formatting for CLI: CLI_TAB = ' ' # Two spaces @@ -112,28 +112,31 @@ DEFAULT_CONFIG = ( # will have filled in all the keys below by the time DEFAULT_CONFIG # is merged in, so the values below are never actually used. They are # listed both to provide a big picture and also so DEFAULT_CONFIG contains - # the keys that should be present after Env._finalize_core() is called. + # at least all the keys that should be present after Env._finalize_core() + # is called. # - # The values are all None so if for some reason any of these keys were - # set from the values here, an exception will be raised. + # Each environment variable below is sent to ``object``, which just happens + # to be an invalid value for an environment variable, so if for some reason + # any of these keys were set from the values here, an exception will be + # raised. # Set in Env.__init__(): - ('ipalib', None), # The directory containing ipalib/__init__.py - ('site_packages', None), # The directory contaning ipalib - ('script', None), # sys.argv[0] - ('bin', None), # The directory containing script - ('home', None), # The home directory of user underwhich process is running - ('dot_ipa', None), # ~/.ipa directory + ('ipalib', object), # The directory containing ipalib/__init__.py + ('site_packages', object), # The directory contaning ipalib + ('script', object), # sys.argv[0] + ('bin', object), # The directory containing script + ('home', object), # The home directory of user underwhich process is running + ('dot_ipa', object), # ~/.ipa directory # Set in Env._bootstrap(): - ('in_tree', None), # Whether or not running in-tree (bool) - ('context', None), # Name of context, default is 'default' - ('conf', None), # Path to config file - ('conf_default', None), # Path to common default config file - ('conf_dir', None), # Directory containing config files + ('in_tree', object), # Whether or not running in-tree (bool) + ('context', object), # Name of context, default is 'default' + ('conf', object), # Path to config file + ('conf_default', object), # Path to common default config file + ('conf_dir', object), # Directory containing config files # Set in Env._finalize_core(): - ('in_server', None), # Whether or not running in-server (bool) - ('log', None), # Path to log file + ('in_server', object), # Whether or not running in-server (bool) + ('log', object), # Path to log file ) -- cgit From 6b055b435f93bf9b63ee9b3b2fdd6f082dacc07b Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 22 Dec 2008 17:29:11 -0700 Subject: Cleaned up Env.__setattr__() and Env.__setitem__() a bit updated their unit tests --- ipalib/constants.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index ef7de44c..c74808d6 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -32,7 +32,12 @@ TYPE_ERROR = '%s: need a %r; got %r (which is a %r)' CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)' # Standard format for StandardError message when overriding an attribute: -OVERRIDE_ERROR = 'cannot override %s value %r with %r' +OVERRIDE_ERROR = 'cannot override %s.%s value %r with %r' + +# Standard format for AttributeError message when a read-only attribute is +# already locked: +LOCK_ERROR = 'locked: cannot set %s.%s to %r' +DEL_ERROR = 'locked: cannot set %s.%s to %r' # Used for a tab (or indentation level) when formatting for CLI: CLI_TAB = ' ' # Two spaces -- cgit From 01cae56e0a19876cf6a614469c0c5e6fb73170e6 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 22 Dec 2008 21:02:43 -0700 Subject: Some more reorganization in Env and added class docstring to Env with lots of examples --- ipalib/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index c74808d6..dc23b109 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -36,8 +36,8 @@ OVERRIDE_ERROR = 'cannot override %s.%s value %r with %r' # Standard format for AttributeError message when a read-only attribute is # already locked: -LOCK_ERROR = 'locked: cannot set %s.%s to %r' -DEL_ERROR = 'locked: cannot set %s.%s to %r' +SET_ERROR = 'locked: cannot set %s.%s to %r' +DEL_ERROR = 'locked: cannot del %s.%s' # Used for a tab (or indentation level) when formatting for CLI: CLI_TAB = ' ' # Two spaces -- cgit From 447c88a2bb9dd364f9c67a73bfce5000ac81d375 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 30 Dec 2008 00:45:48 -0700 Subject: Started moving some core classes and functions from plugable.py to new base.py module --- ipalib/constants.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ipalib/constants.py') diff --git a/ipalib/constants.py b/ipalib/constants.py index dc23b109..5687c53e 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -25,8 +25,14 @@ All constants centralised in one file. # The parameter system treats all these values as None: NULLS = (None, '', u'', tuple(), []) +# regular expression NameSpace member names must match: +NAME_REGEX = r'^[a-z][_a-z0-9]*[a-z0-9]$' + +# Format for ValueError raised when name does not match above regex: +NAME_ERROR = 'name must match %r; got %r' + # Standard format for TypeError message: -TYPE_ERROR = '%s: need a %r; got %r (which is a %r)' +TYPE_ERROR = '%s: need a %r; got %r (a %r)' # Stardard format for TypeError message when a callable is expected: CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)' @@ -37,7 +43,7 @@ OVERRIDE_ERROR = 'cannot override %s.%s value %r with %r' # Standard format for AttributeError message when a read-only attribute is # already locked: SET_ERROR = 'locked: cannot set %s.%s to %r' -DEL_ERROR = 'locked: cannot del %s.%s' +DEL_ERROR = 'locked: cannot delete %s.%s' # Used for a tab (or indentation level) when formatting for CLI: CLI_TAB = ' ' # Two spaces -- cgit