Package gavo :: Package rscdef :: Module common
[frames] | no frames]

Module common

source code

Common items used by resource definition objects.

Classes
  RDAttribute
an attribute that gives access to the current rd.
  ResdirRelativeAttribute
is a path that is interpreted relative to the current RD's resdir.
  ProfileListAttribute
An attribute containing a comma separated list of profile names.
  PrivilegesMixin
A mixin for structures declaring access to database objects (tables, schemas).
  IVOMetaMixin
A mixin for resources aspiring to have IVO ids.
  Registration
A request for registration of a data or table item.
  ColumnList
A list of column.Columns (or derived classes) that takes care that no duplicates (in name) occur.
  ColumnListAttribute
An adapter from a ColumnList to a structure attribute.
  NamePathAttribute
defines an attribute NamePath used for resolution of "original" attributes.
Functions
 
replaceProcDefAt(src, dictName='vars')
replaces @<identifier> with <dictName>["<identifier>"] in src.
source code
 
getReferencedElement(refString, forceType=None, **kwargs)
returns the element for the DaCHS reference ``refString``.
source code
 
getStandardPubDID(path)
returns the standard DaCHS PubDID for ``path``.
source code
 
getDatalinkMetaLink(dlSvc, accref)
returns a datalink URL for the product referenced through accref with the datalink service dlSvc.
source code
 
getAccrefFromStandardPubDID(pubdid, authBase=u'ivo://org.gavo.dc/~?')
returns an accref from a standard DaCHS PubDID.
source code
 
getInputsRelativePath(absPath, liberalChars=True)
returns absath relative to the DaCHS inputsDir.
source code
Variables
  __package__ = 'gavo.rscdef'
Function Details

replaceProcDefAt(src, dictName='vars')

source code 

replaces @<identifier> with <dictName>["<identifier>"] in src.

We do this to support this shortcut in the vicinity of rowmakers (i.e., there and in procApps).

getReferencedElement(refString, forceType=None, **kwargs)

source code 

returns the element for the DaCHS reference ``refString``.

``refString`` has the form ``rdId[#subRef]``; ``rdId`` can be filesystem-relative, but the RD referenced must be below ``inputsDir`` anyway.

You can pass a structure class into ``forceType``, and a ``StructureError`` will be raised if what's pointed to by the id isn't of that type.

You should usually use ``base.resolveCrossId`` instead of this from *within* DaCHS. This is intended for code handling RD ids from users.

This supports further keyword arguments to getRD.

getStandardPubDID(path)

source code 

returns the standard DaCHS PubDID for ``path``.

The publisher dataset identifier (PubDID) is important in protocols like SSAP and obscore. If you use this function, the PubDID will be your authority, the path compontent ~, and the inputs-relative path of the input file as the parameter.

``path`` can be relative, in which case it is interpreted relative to the DaCHS ``inputsDir.``

You *can* define your PubDIDs in a different way, but you'd then need to provide a custom descriptorGenerator to datalink services (and might need other tricks). If your data comes from plain files, use this function.

In a rowmaker, you'll usually use the \standardPubDID macro.

Decorators:
  • @utils.document

getDatalinkMetaLink(dlSvc, accref)

source code 

returns a datalink URL for the product referenced through accref with the datalink service dlSvc.

This assumes that dlSvc uses the standard DaCHS pubDIDs. dlSvc needs to be the service element.

A typical use is in a metaMaker and would look like this:

       getDatalinkMetaLink(rd.getById("dl"), descriptor.accref)
Decorators:
  • @utils.document

getAccrefFromStandardPubDID(pubdid, authBase=u'ivo://org.gavo.dc/~?')

source code 

returns an accref from a standard DaCHS PubDID.

This is basically the inverse of getStandardPubDID. It will raise NotFound if pubdid "looks like a URI" (implementation detail: has a colon in the first 10 characters) and does not start with ivo://<authority>/~?. If it's not a URI, we assume it's a local accref and just return it.

The function does not check if the remaining characters are a valid accref, much less whether it can be resolved.

authBase's default will reflect you system's settings on your installation, which probably is not what's given in this documentation.

Decorators:
  • @utils.document

getInputsRelativePath(absPath, liberalChars=True)

source code 

returns absath relative to the DaCHS inputsDir.

If ``absPath`` is not below ``inputsDir``, a ``ValueError`` results. On ``liberalChars``, wee see the `function getRelativePath`_.

In rowmakers and rowfilters, you'll usually use the macro ``\inputRelativePath`` that inserts the appropriate code.

Decorators:
  • @utils.document