From 7be459af0b52753ccde74e6833d664341935973d Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 2 Jan 2009 01:14:37 -0700 Subject: Added a bit to config.Env docstring about that variable names must pass check_name() function --- ipalib/config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ipalib/config.py') diff --git a/ipalib/config.py b/ipalib/config.py index 6feae5735..04f1442fd 100644 --- a/ipalib/config.py +++ b/ipalib/config.py @@ -65,6 +65,20 @@ class Env(object): >>> env.item # Also retrieve as an attribute 'I was set as a dictionary item.' + The variable names must be valid lower-case Python identifiers that neither + start nor end with an underscore. If your variable name doesn't meet these + criteria, a ``ValueError`` will be raised when you try to set the variable + (compliments of the `base.check_name()` function). For example: + + >>> env.BadName = 'Wont work as an attribute' + Traceback (most recent call last): + ... + ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$'; got 'BadName' + >>> env['BadName'] = 'Also wont work as a dictionary item' + Traceback (most recent call last): + ... + ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$'; got 'BadName' + The variable values can be ``str``, ``int``, or ``float`` instances, or the ``True``, ``False``, or ``None`` constants. When the value provided is an ``str`` instance, some limited automatic type conversion is performed, which -- cgit