gavo.base.config module¶
Definition of DC config options and their management including I/O.
-
class
gavo.base.config.
AuthorityConfigItem
(name, default=None, description='Undocumented')[source]¶ Bases:
gavo.utils.fancyconfig.StringConfigItem
an IVOA Identifers-compatible authority.
-
class
gavo.base.config.
Configuration
(*items)[source]¶ Bases:
gavo.utils.fancyconfig.Configuration
A container for settings.
It is a fancyconfig.Configuration with the addition of making the attributes shared at the class level to ward against multiple imports (which may happen if config is imported in a weird way).
In addition, this class handles the access to database profiles.
-
class
gavo.base.config.
DBProfile
(parent, **kwargs)[source]¶ Bases:
gavo.base.structure.Structure
is a profile for DB access.
-
attrSeq
= [<gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.parsecontext.IdAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.IntAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>, <gavo.base.attrdef.UnicodeAttribute object>]¶
-
completedCallbacks
= []¶
-
managedAttrs
= {'database': <gavo.base.attrdef.UnicodeAttribute object>, 'host': <gavo.base.attrdef.UnicodeAttribute object>, 'id': <gavo.base.parsecontext.IdAttribute object>, 'name': <gavo.base.attrdef.UnicodeAttribute object>, 'password': <gavo.base.attrdef.UnicodeAttribute object>, 'port': <gavo.base.attrdef.IntAttribute object>, 'sslmode': <gavo.base.attrdef.UnicodeAttribute object>, 'user': <gavo.base.attrdef.UnicodeAttribute object>}¶
-
name_
= 'dbProfile'¶
-
profileName
= 'anonymous'¶
-
property
roleName
¶ returns the database role used by this profile.
This normally is user, but in the special case of the empty user, we return the logged users’ name.
-
-
class
gavo.base.config.
EatTrailingSlashesItem
(name, default=None, description='Undocumented')[source]¶ Bases:
gavo.utils.fancyconfig.StringConfigItem
is a config item that must not end with a slash. A trailing slash on input is removed.
-
typedesc
= 'path fragment'¶
-
-
class
gavo.base.config.
EnsureTrailingSlashesItem
(name, default=None, description='Undocumented')[source]¶ Bases:
gavo.utils.fancyconfig.StringConfigItem
is a config item that must end with a slash. If no slash is present on input, it is added.
-
typedesc
= 'path fragment'¶
-
-
exception
gavo.base.config.
Error
(msg='', hint=None)[source]¶ Bases:
gavo.utils.excs.Error
-
exception
gavo.base.config.
ProfileParseError
(msg='', hint=None)[source]¶ Bases:
gavo.base.config.Error
-
class
gavo.base.config.
ProfileParser
(sourcePath=['.'])[source]¶ Bases:
object
is a parser for DB profiles.
The profiles are specified in simple text files that have a shell-like syntax. Each line either contains an assignment (x=y) or is of the form command arg*. Recognized commands include:
include f – read instructions from file f, searched along profilePath
>>> p = ProfileParser() >>> p.parse(None, "x", "host=foo.bar\n").host 'foo.bar' >>> p.parse(None, "x", "") is not None True >>> p.parse(None, "x", "host=\n").host '' >>> p.parse(None, "x", "=bla\n") Traceback (most recent call last): gavo.base.config.ProfileParseError: "x", line 1: invalid identifier '=' >>> p.parse(None, "x", "host=bla") Traceback (most recent call last): gavo.base.config.ProfileParseError: "x", line 1: unexpected end of file (missing line feed?)
-
profileKeys
= {'database', 'host', 'password', 'port', 'sslmode', 'user'}¶
-
class
gavo.base.config.
RelativeURL
(name, default=None, description='Undocumented')[source]¶ Bases:
gavo.utils.fancyconfig.StringConfigItem
is a configuration item that is interpreted relative to the server’s root URL.
-
typedesc
= "URL fragment relative to the server's root"¶
-
property
value
¶
-
-
class
gavo.base.config.
RootRelativeConfigItem
(name, default=None, description='Undocumented')[source]¶ Bases:
gavo.utils.fancyconfig.PathRelativeConfigItem
-
baseKey
= 'rootDir'¶
-
typedesc
= 'path relative to rootDir'¶
-
-
class
gavo.base.config.
WebRelativeConfigItem
(name, default=None, description='Undocumented')[source]¶ Bases:
gavo.utils.fancyconfig.PathRelativeConfigItem
-
baseKey
= 'webDir'¶
-
typedesc
= 'path relative to webDir'¶
-
-
gavo.base.config.
getDBProfile
(profileName)¶
-
gavo.base.config.
getRSTReference
(underlineChar='-')[source]¶ returns a ReStructuredText reference of configuration items.
This will have one RST section per configuration section; to let you adapt that to an embedding document, you can pass the character to use for headline underlines in underlineChar.
-
gavo.base.config.
makeFallbackMeta
(reload=False)[source]¶ fills meta.configMeta with items from $configDir/defaultmeta.txt.
This is called from the module __init__ once typed meta from base is in (which means that any typed meta defined in other places won’t become magic in fallback; regrettably, we can’t hold off loading fallback meta much longer).