Home | Trees | Index | Help |
|
---|
Package Cheetah :: Module SettingsManager :: Class _SettingsCollector |
|
SettingsManager
An abstract base class that provides the methods SettingsManager uses to collect settings from config files and SettingsContainers. This class only collects settings it doesn't modify the _settings dictionary of SettingsManager instances in any way. SettingsCollector is designed to: - be able to read settings from Python src files (or strings) so that complex Python objects can be stored in the application's settings dictionary. For example, you might want to store references to various classes that are used by the application and plugins to the application might want to substitute one class for another. - be able to read/write .ini style config files (or strings) - allow sections in .ini config files to be extended by settings in Python src files - allow python literals to be used values in .ini config files - maintain the case of setting names, unlike the ConfigParser module
Method Summary | |
---|---|
__init__(self)
| |
Extract all the attributes of a SettingsContainer subclass. | |
Check if 'thing' is a Python module or a subclass of SettingsContainer. | |
A hook for any neccessary path manipulations. | |
readSettingsFromConfigFile(self,
path,
convert)
| |
Return the settings from a config file that uses the syntax accepted by Python's standard ConfigParser module (like Windows .ini files). | |
Returns all settings from a SettingsContainer or Python module. | |
Returns all settings from a SettingsContainer or Python module. | |
Return new settings dict from variables in a Python source file. | |
Return a dictionary of the settings in a Python src string. |
Class Variable Summary | |
---|---|
classobj |
_ConfigParserClass = Cheetah.SettingsManager.ConfigParserCaseSensitive |
lock |
_sysPathLock = <thread.lock object at 0xb7df8340>
|
Method Details |
---|
_getAllAttrsFromContainer(self, container)Extract all the attributes of a SettingsContainer subclass. The 'container' is a class, so extracting all attributes from it, an instance of it, and all its base classes. This method is not recursive. |
_isContainer(self, thing)Check if 'thing' is a Python module or a subclass of SettingsContainer. |
normalizePath(self, path)A hook for any neccessary path manipulations. For example, when this is used with WebKit servlets all relative paths must be converted so they are relative to the servlet's directory rather than relative to the program's current working dir. The default implementation just normalizes the path for the current operating system. |
readSettingsFromConfigFileObj(self, inFile, convert=True)Return the settings from a config file that uses the syntax accepted by Python's standard ConfigParser module (like Windows .ini files). NOTE: this method maintains case unlike the ConfigParser module, unless this class was initialized with the 'caseSensitive' keyword set to False. All setting values are initially parsed as strings. However, If the 'convert' arg is True this method will do the following value conversions: * all Python numeric literals will be coverted from string to number * The string 'None' will be converted to the Python value None * The string 'True' will be converted to a Python truth value * The string 'False' will be converted to a Python false value * Any string starting with 'python:' will be treated as a Python literal or expression that needs to be eval'd. This approach is useful for declaring lists and dictionaries. If a config section titled 'Globals' is present the options defined under it will be treated as top-level settings. |
readSettingsFromContainer(self, container, ignoreUnderscored=True)Returns all settings from a SettingsContainer or Python module. This method is recursive. |
readSettingsFromModule(self, container, ignoreUnderscored=True)Returns all settings from a SettingsContainer or Python module. This method is recursive. |
readSettingsFromPySrcFile(self, path)Return new settings dict from variables in a Python source file. This method will temporarily add the directory of src file to sys.path so that import statements relative to that dir will work properly. |
readSettingsFromPySrcStr(self, theString)Return a dictionary of the settings in a Python src string. |
Class Variable Details |
---|
_sysPathLock
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007 | http://epydoc.sf.net |