1313
1414class GlobalConfig (object ):
1515"""
16- Globalconfig ( override default settings) .
16+ Globalconfiguration object which allows user to override default settings.
1717
1818 Attributes:
1919 cache_initdb: shall we use cached initdb instance?
20- cached_initdb_dir:shall we create a tempdir for cached initdb?
21- cached_initdb_unique: shall weassign new node a unique system id?
20+ cached_initdb_dir:path to a tempdirectory for cached initdb.
21+ cached_initdb_unique: shall wegive new node a unique system id?
2222
2323 cache_pg_config: shall we cache pg_config results?
2424
25- temp_dir:base temp dirfor nodes with default 'base_dir'.
25+ temp_dir:path to temp dircontaining nodes with default 'base_dir'.
2626
27- use_python_logging:use python loggingconfiguration for all nodes .
28- error_log_lines: N of log lines to be shown inexception (0=inf).
27+ use_python_logging:enable python loggingsubsystem (see logger.py) .
28+ error_log_lines: N of log lines to be shown inexceptions (0=inf).
2929
3030 node_cleanup_full: shall we remove EVERYTHING (including logs)?
3131 node_cleanup_on_good_exit: remove base_dir on nominal __exit__().
@@ -82,6 +82,10 @@ def __setattr__(self, name, value):
8282super (GlobalConfig ,self ).__setattr__ (name ,value )
8383
8484def keys (self ):
85+ """
86+ Return a list of all available settings.
87+ """
88+
8589keys = []
8690
8791for key in dir (GlobalConfig ):
@@ -91,15 +95,29 @@ def keys(self):
9195return keys
9296
9397def items (self ):
98+ """
99+ Return setting-value pairs.
100+ """
101+
94102return ((key ,self [key ])for key in self .keys ())
95103
96104def update (self ,config ):
105+ """
106+ Extract setting-value pairs from 'config' and
107+ assign those values to corresponding settings
108+ of this GlobalConfig object.
109+ """
110+
97111for key ,value in config .items ():
98112self [key ]= value
99113
100114return self
101115
102116def copy (self ):
117+ """
118+ Return a copy of this object.
119+ """
120+
103121return copy .copy (self )
104122
105123
@@ -124,8 +142,8 @@ def _rm_cached_initdb_dirs():
124142
125143def push_config (** options ):
126144"""
127- Permanently set custom GlobalConfig options
128- and put previous settings on top of stack.
145+ Permanently set custom GlobalConfig options and
146+ put previous settings on top of the config stack.
129147 """
130148
131149# push current config to stack
@@ -150,10 +168,12 @@ def pop_config():
150168def scoped_config (** options ):
151169"""
152170 Temporarily set custom GlobalConfig options for this context.
171+ Previous options are pushed to the config stack.
153172
154173 Example:
155174 >>> from .api import get_new_node
156175 >>> with scoped_config(cache_initdb=False):
176+ ... # create a new node with fresh initdb
157177 ... with get_new_node().init().start() as node:
158178 ... print(node.execute('select 1'))
159179 [(1,)]
@@ -173,7 +193,7 @@ def scoped_config(**options):
173193def configure_testgres (** options ):
174194"""
175195 Adjust current global options.
176- Look at GlobalConfig to learnwhat can be set .
196+ Look atthe GlobalConfig to learnabout existing settings .
177197 """
178198
179199testgres_config .update (options )