gavo.rsc.common module

Helpers for resource creation.

exception gavo.rsc.common.DBTableError(msg, qName, hint=None)[source]

Bases: Error

is raised when a manipulation of an on-disk table fails.

It always has a qName attribute containing the qualified name of the table causing the trouble.

class gavo.rsc.common.FLUSH[source]

Bases: object

A sentinel that grammars can yield to flush out records to the Database.

This probably is only necessary in updating dispatched grammars to enforce dropping of rows dependent on some table.

class gavo.rsc.common.ParamMixin[source]

Bases: object

A mixin providing param processing.

This is for tables and data elements. If you mix this in, you have to call _initParams(rscdefObject, params=None)

rscdefObject is a TableDef or DataDef, params, if given, a dictionary mapping param names to param values.

getParam(parName, default=<Not given/empty>)[source]

retrieves a parameter (python) value.

getParamByName(parName)[source]
getParamByUtype(utype)[source]
getParamDict()[source]
iterParams()[source]

iterates over the parameters for this table.

The items returned are rscdef.Param instances.

setParam(parName, value)[source]

sets a parameter to a value.

String-typed values will be parsed, everything else is just entered directly. Trying to write to non-existing params will raise a NotFoundError.

Do not write to params directly, you’ll break things.

setParams(parDict, raiseOnBadKeys=True)[source]
class gavo.rsc.common.ParseOptions[source]

Bases: object

see `function getParseOptions`_ .

change(**kwargs)[source]

returns a copy of self with the keyword parameters changed.

Trying to add attributes in this way will raise an AttributeError.

>>> p = parseValidating.change(validateRows=False)
>>> p.validateRows
False
>>> p.change(gulp=1)
Traceback (most recent call last):
AttributeError: ParseOptions instances have no gulp attributes
gavo.rsc.common.getParseOptions(validateRows=True, doTableUpdates=False, batchSize=1024, maxRows=None, keepGoing=False, dropIndices=False, dumpRows=False, metaOnly=False, buildDependencies=True, systemImport=False, commitAfterMeta=False, dumpIngestees=False, suppressMeta=False, metaPlusIndex=False)[source]

returns an object with some attributes set.

This object is used in the parsing code in dddef. It’s a standin for the the command line options for tables created internally and should have all attributes that the parsing infrastructure might want from the optparse object.

So, just configure what you want via keyword arguments or use the prebuilt objects parseValidating and and parseNonValidating below.

See commandline.py for the meaning of the attributes.

The exception is buildDependencies. This is true for most internal builds of data (and thus here), but false when we need to manually control when dependencies are built, as in user.importing and while building the dependencies themselves.