Python Manual User Manual

Page of 124
19
Program Setup
As Python is an interpreted language, configuration of an application can be carried out by editing the
actual scripts. In some circumstances however, it is still easier or more practical to rely upon a config-
uration database or environment variables. When using OSE this is especially the case, as an applica-
tion can be a mix of C++ and Python code and configuration data may need to be accessible from code
written in both languages.
To support this the Python wrappers provide an interface to the configuration database of the OSE C++
class library. The corresponding class in the OSE C++ class library which provides this functionality
is the
OTC_Program
class. Not all functionality of this class is mirrored in the Python interface as
Python has its own way of doing most of what is provided by this class. Access is however provided
to aspects of the configuration database and environment variable database. The functionality for gen-
erating unique identifiers is also exposed.
Configuration Database
The configuration database is an in memory database. The database may be populated by calls from
within the application, or by loading in a configuration file. The configuration database may also be
saved to a file. In essence, the configuration database is not much more than a dictionary mapping
names to values.
To initially load the configuration database from a file, the "
loadConfig()
" function is used. A sin-
gle configuration item may be explicitly merged into the configuration database using the
"
mergeConfig()
" function. A query can subsequently be made against the configuration database
using the "
lookupConfig()
" function. If no match is found in the configuration database for the
item in question, the value
None
is returned.