Set a configuration variable to a specific value. By using this method, you can override the normal lookup process used in ``get_config_variable`` by explicitly setting a value. Subsequent calls to ``get_config_variable`` will use the ``value``. This gives you per-
(self, logical_name, value)
| 310 | return value |
| 311 | |
| 312 | def set_config_variable(self, logical_name, value): |
| 313 | """Set a configuration variable to a specific value. |
| 314 | |
| 315 | By using this method, you can override the normal lookup |
| 316 | process used in ``get_config_variable`` by explicitly setting |
| 317 | a value. Subsequent calls to ``get_config_variable`` will |
| 318 | use the ``value``. This gives you per-session specific |
| 319 | configuration values. |
| 320 | |
| 321 | :: |
| 322 | >>> # Assume logical name 'foo' maps to env var 'FOO' |
| 323 | >>> os.environ['FOO'] = 'myvalue' |
| 324 | >>> s.get_config_variable('foo') |
| 325 | 'myvalue' |
| 326 | >>> s.set_config_variable('foo', 'othervalue') |
| 327 | >>> s.get_config_variable('foo') |
| 328 | 'othervalue' |
| 329 | |
| 330 | :type logical_name: str |
| 331 | :param logical_name: The logical name of the session variable |
| 332 | you want to set. These are the keys in ``SESSION_VARIABLES``. |
| 333 | :param value: The value to associate with the config variable. |
| 334 | |
| 335 | """ |
| 336 | logger.debug( |
| 337 | "Setting config variable for %s to %r", |
| 338 | logical_name, |
| 339 | value, |
| 340 | ) |
| 341 | self._session_instance_vars[logical_name] = value |
| 342 | |
| 343 | def instance_variables(self): |
| 344 | return copy.copy(self._session_instance_vars) |
no outgoing calls