Package gavo :: Package rscdef :: Module tabledef :: Class TableDef
[frames] | no frames]

Class TableDef

source code

                   object --+            
                            |            
 base.structure.StructureBase --+        
                                |        
                   object --+   |        
                            |   |        
           base.common.Parser --+        
                                |        
base.structure.ParseableStructure --+    
                                    |    
             base.structure.Structure --+
                                        |
                       object --+       |
                                |       |
              base.meta.MetaMixin --+   |
                                    |   |
          base.meta.ComputedMetaMixin --+
                                        |
                           object --+   |
                                    |   |
               common.PrivilegesMixin --+
                                        |
                           object --+   |
                                    |   |
                  common.IVOMetaMixin --+
                                        |
                       object --+       |
                                |       |
         base.macros.MacroPackage --+   |
                                    |   |
       base.macros.StandardMacroMixin --+
                                        |
                           object --+   |
                                    |   |
                 PublishableDataMixin --+
                                        |
                                       TableDef
Known Subclasses:

A definition of a table, both on-disk and internal.

Some attributes are ignored for in-memory tables, e.g., roles or adql.

Properties for tables:

* supportsModel -- a short name of a data model supported through this 
  table (for TAPRegExt dataModel); you can give multiple names separated
  by commas.
* supportsModelURI -- a URI of a data model supported through this table.
  You can give multiple URIs separated by blanks.

If you give multiple data model names or URIs, the sequences of names and 
URIs must be identical (in particular, each name needs a URI).

Nested Classes

Inherited from base.structure.StructureBase: __metaclass__

Instance Methods
 
__contains__(self, name) source code
 
__iter__(self) source code
 
__repr__(self)
repr(x)
source code
 
clearProperty(self, name) source code
 
completeElement(self, ctx) source code
 
doSimpleQuery(self, selectClause=None, fragments='', params=None, postfix='')
runs a query generated via getSimpleQuery and returns a list of rowdicts.
source code
 
getByName(self, name)
returns the column or param with name.
source code
 
getByUtype(self, utype)
returns the column or param with utype.
source code
 
getByUtypes(self, *utypes)
returns the first param or column matching the first utype matching anything.
source code
 
getColumnById(self, id) source code
 
getColumnByName(self, name) source code
 
getColumnByUCD(self, ucd) source code
 
getColumnByUCDs(self, *ucds) source code
 
getColumnsByUCD(self, ucd) source code
 
getColumnsByUCDs(self, *ucds) source code
 
getDDL(self)
returns an SQL statement that creates the table.
source code
 
getDefaults(self)
returns a mapping from column names to defaults to be used when making a row for this table.
source code
 
getElementForName(self, name)
returns the first of column and param having name name.
source code
 
getFieldIndex(self, fieldName)
returns the index of the field named fieldName.
source code
 
getFullId(self) source code
 
getNote(self, noteTag)
returns the table note meta value for noteTag.
source code
 
getParamByName(self, name) source code
 
getPrimaryIn(self, row) source code
 
getProperty(self, name, default=<Undefined>) source code
 
getQName(self) source code
 
getSTCDefs(self)
returns a set of all STC specs referenced in this table as ASTs.
source code
 
getSimpleQuery(self, selectClause=None, fragments='', postfix='')
returns a query against this table.
source code
 
getURL(self, rendName, absolute=True)
returns the URL DaCHS will show the table info page for this table under.
source code
 
hasProperty(self, name) source code
 
iterAnnotationsOfType(instance, typeName)
returns the first annotation of the type passed.
source code
 
macro_colNames(self)
returns an SQL-ready list of column names of this table.
source code
 
macro_curtable(self)
returns the qualified name of the current table.
source code
 
macro_getParam(self, parName, default='')
returns the string representation of the parameter parName.
source code
 
macro_nameForUCD(self, ucd)
returns the (unique!) name of the field having ucd in this table.
source code
 
macro_nameForUCDs(self, ucds)
returns the (unique!) name of the field having one of ucds in this table.
source code
 
macro_qName(self)
returns the qualified name of the current table.
source code
 
macro_tablename(self)
returns the unqualified name of the current table.
source code
 
makeRowFromTuple(self, dbTuple)
returns a row (dict) from a row as returned from the database.
source code
 
mixesIn(instance, mixinRef) source code
 
onElementComplete(self) source code
 
resolveName(instance, context, id) source code
 
setProperty(self, name, value) source code
 
updateAnnotationFromChildren(instance) source code
 
validate(self) source code
 
validateRow(self, row)
checks that row is complete and complies with all known constraints on the columns
source code

Inherited from base.structure.Structure: __provides__, callCompletedCallbacks, finishElement

Inherited from base.structure.ParseableStructure: __init__, end_, feed, feedFrom, feedObject, getAttribute, iterEvents, start_, value_

Inherited from base.structure.StructureBase: __providedBy__, adopt, breakCircles, change, copy, getAttributes, getCopyableAttributes, getSourcePosition, iterChildren, setPosition

Inherited from base.common.Parser: feedEvent

Inherited from base.meta.ComputedMetaMixin: getMetaKeys

Inherited from base.meta.MetaMixin: addMeta, buildRepr, copyMetaFrom, delMeta, getAllMetaPairs, getMeta, getMetaParent, isEmpty, iterMeta, keys, makeOriginal, setMeta, setMetaParent, traverse

Inherited from base.macros.StandardMacroMixin: macro_RSTservicelink, macro_RSTtable, macro_decapitalize, macro_getConfig, macro_internallink, macro_magicEmpty, macro_metaSeq, macro_metaString, macro_rdId, macro_rdIdDotted, macro_schema, macro_test, macro_today, macro_upper, macro_urlquote

Inherited from base.macros.MacroPackage: execMacro, expand, getExpander, listMacros, macro_quote, macro_reSub, macro_sql_standardPubDID, macro_sqlquote

Inherited from PublishableDataMixin: getPublicationsForSet

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
fromColumns(cls, columns, **kwargs)
returns a TableDef from a sequence of columns.
source code

Inherited from base.structure.StructureBase: fromStructure

Static Methods
 
disambiguateColumns(columns)
returns a sequence of columns without duplicate names.
source code
Class Variables
  attrSeq = [<gavo.rscdef.tabledef.ADQLVisibilityAttribute objec...
  fixupFunction = None
hash(x)
  managedAttrs = {'adql': <gavo.rscdef.tabledef.ADQLVisibilityAt...
  metaModel = 'title(1), creationDate(1), description(1),subject...
  name_ = 'table'
hash(x)
  resType = 'table'
hash(x)

Inherited from base.structure.Structure: __implemented__

Inherited from base.structure.StructureBase: completedCallbacks

Properties
  caseFixer
  rd

Inherited from object: __class__

Method Details

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

completeElement(self, ctx)

source code 
Overrides: base.structure.Structure.completeElement

doSimpleQuery(self, selectClause=None, fragments='', params=None, postfix='')

source code 

runs a query generated via getSimpleQuery and returns a list of rowdicts.

This uses a table connection and queryToDicts; the keys in the dictionaries will have the right case for this table's columns, though.

params is a dictionary of fillers for fragments and postfix.

fromColumns(cls, columns, **kwargs)
Class Method

source code 

returns a TableDef from a sequence of columns.

You can give additional constructor arguments. makeStruct is used to build the instance, the mixin hack is applied.

Columns with identical names will be disambiguated.

getByName(self, name)

source code 

returns the column or param with name.

There is nothing keeping you from having both a column and a param with the same name. If that happens, you will only see the column. But don't do it.

getByUtype(self, utype)

source code 

returns the column or param with utype.

This is supposed to be unique, but the function will just return the first matching item it finds.

getElementForName(self, name)

source code 

returns the first of column and param having name name.

The function raises a NotFoundError if neiter column nor param with name exists.

getNote(self, noteTag)

source code 

returns the table note meta value for noteTag.

This will raise a NotFoundError if we don't have such a note.

You will not usually use this to retrieve meta items since columns have the meta values in their note attributes. Columns, of course, use this to get their note attribute value.

getSimpleQuery(self, selectClause=None, fragments='', postfix='')

source code 

returns a query against this table.

selectClause is a list of column names (in which case the names are validated against the real column names and you can use user input) or a literal string (in which case you must not provide user input or have a SQL injection hole).

fragments (the WHERE CLAUSE) and postfix are taken as literal strings (so they must not contain user input).

This is purely a string operation, so you'll have your normal value references in fragments and postfix, and should maintain the parameter dictionaries as usual.

All parts are optional, defaulting to pulling the entire table.

getURL(self, rendName, absolute=True)

source code 

returns the URL DaCHS will show the table info page for this table under.

Of course the URL is only valid for imported tables.

macro_curtable(self)

source code 

returns the qualified name of the current table.

(this is identical to the `macro qName`_, which you should prefer in new RDs.)

macro_getParam(self, parName, default='')

source code 

returns the string representation of the parameter parName.

This is the parameter as given in the table definition. Any changes to an instance are not reflected here.

If the parameter named does not exist, an empty string is returned. NULLs/Nones are rendered as NULL; this is mainly a convenience for obscore-like applications and should not be exploited otherwise, since it's ugly and might change at some point.

If a default is given, it will be returned for both NULL and non-existing params.

macro_nameForUCD(self, ucd)

source code 

returns the (unique!) name of the field having ucd in this table.

If there is no or more than one field with the ucd in this table, we raise a ValueError.

macro_nameForUCDs(self, ucds)

source code 

returns the (unique!) name of the field having one of ucds in this table.

Ucds is a selection of ucds separated by vertical bars (|). The rules for when this raises errors are so crazy you don't want to think about them. This really is only intended for cases where "old" and "new" standards are to be supported, like with pos.eq.*;meta.main and POS_EQ_*_MAIN.

If there is no or more than one field with the ucd in this table, we raise an exception.

macro_tablename(self)

source code 

returns the unqualified name of the current table.

In most contexts, you will probably need to use the `macro qName`_ instead of this.

onElementComplete(self)

source code 
Overrides: base.structure.Structure.onElementComplete

validate(self)

source code 
Overrides: base.structure.Structure.validate

validateRow(self, row)

source code 

checks that row is complete and complies with all known constraints on the columns

The function raises a ValidationError with an appropriate message and the relevant field if not.


Class Variable Details

attrSeq

Value:
[<gavo.rscdef.tabledef.ADQLVisibilityAttribute object>,
 <gavo.rscdef.common.ProfileListAttribute object>,
 <gavo.dm.dmrd.DataModelRolesAttribute object>,
 <gavo.rscdef.common.ColumnListAttribute object>,
 <gavo.base.attrdef.EnumeratedUnicodeAttribute object>,
 <gavo.base.attrdef.BooleanAttribute object>,
 <gavo.base.complexattrs.StructListAttribute object>,
 <gavo.base.complexattrs.StructListAttribute object>,
...

managedAttrs

Value:
{'adql': <gavo.rscdef.tabledef.ADQLVisibilityAttribute object>,
 'allProfiles': <gavo.rscdef.common.ProfileListAttribute object>,
 'column': <gavo.rscdef.common.ColumnListAttribute object>,
 'columns': <gavo.rscdef.common.ColumnListAttribute object>,
 'dm': <gavo.dm.dmrd.DataModelRolesAttribute object>,
 'dupePolicy': <gavo.base.attrdef.EnumeratedUnicodeAttribute object>,
 'forceUnique': <gavo.base.attrdef.BooleanAttribute object>,
 'foreignKey': <gavo.base.complexattrs.StructListAttribute object>,
...

metaModel

Value:
'title(1), creationDate(1), description(1),subject, referenceURL(1)'

Property Details

caseFixer

Get Method:
unreachable.caseFixer(self)

rd

Get Method:
unreachable._getRD(self)