| 1 | """ |
| 2 | Output tables and their components. |
| 3 | """ |
| 4 | |
| 5 | #c Copyright 2008-2025, the GAVO project <[email protected]> |
| 6 | #c |
| 7 | #c This program is free software, covered by the GNU GPL. See the |
| 8 | #c COPYING file in the source distribution. |
| 9 | |
| 10 | |
| 11 | import fnmatchscip-python python python-stdlib 3.11 fnmatch/__init__: |
| 12 | |
| 13 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import basescip-python python gavodachs 2.13 `gavo.base`/__init__: |
| 14 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__: |
| 15 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__: |
| 16 | |
| 17 | _EMPTY_TABLEscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/_EMPTY_TABLE. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.TableDefscip-python python gavodachs 2.13 `gavo.base.structure`/TableDef#, id="<builtin empty table>") |
| 18 | _EMPTY_TABLEscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/_EMPTY_TABLE..getFullId = lambda: None |
| 19 | |
| 20 | |
| 21 | class OutputFieldscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#(rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.Columnscip-python python gavodachs 2.13 `gavo.base.structure`/Column#): |
| 22 | """A column for defining the output of a service. |
| 23 | |
| 24 | It adds some attributes useful for rendering results, plus functionality |
| 25 | specific to certain cores. |
| 26 | |
| 27 | The optional formatter overrides the standard formatting code in HTML |
| 28 | (which is based on units, ucds, and displayHints). You receive |
| 29 | the item from the database as data and must return a string or |
| 30 | t.w.template stan. In addition to the standard `Functions available for |
| 31 | row makers`_ you have queryMeta and t.w.template's tags in T. |
| 32 | |
| 33 | Here's an example for generating a link to another service using this |
| 34 | facility:: |
| 35 | |
| 36 | <outputField name="more" |
| 37 | select="array[centerAlpha,centerDelta]" tablehead="More" |
| 38 | description="More exposures near the center of this plate"> |
| 39 | <formatter><![CDATA[ |
| 40 | return T.a(href=base.makeSitePath("/lswscans/res/positions/q/form?" |
| 41 | "POS=%s,%s&SIZE=1&INTERSECT=OVERLAPS&cutoutSize=0.5" |
| 42 | "&__nevow_form__=genForm"%tuple(data) |
| 43 | ))["More"] ]]> |
| 44 | </formatter> |
| 45 | </outputField> |
| 46 | |
| 47 | Within the code, in addition to data, you see rd and queryMeta. |
| 48 | """ |
| 49 | name_scip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#name_. = "outputField" |
| 50 | |
| 51 | _formatterscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#_formatter. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.UnicodeAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("formatter", description="Function" |
| 52 | " body to render this item to HTML.", copyable=True, expand=True) |
| 53 | _wantsRowscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#_wantsRow. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.BooleanAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("wantsRow", descriptionscip-python python gavodachs 2.13 `gavo.base.attrdef`/AttributeDef#__init__().(description)="Does" |
| 54 | " formatter expect the entire row rather than the column value only?", |
| 55 | copyablescip-python python gavodachs 2.13 `gavo.base.attrdef`/AttributeDef#__init__().(copyable)="True") |
| 56 | _selectscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#_select. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.UnicodeAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("select", description="Use this SQL" |
| 57 | " fragment rather than field name in the select list of a DB based" |
| 58 | " core.", default=basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Undefinedscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#, copyable=True, expand=True) |
| 59 | _setsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#_sets. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StringSetAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("sets", description= |
| 60 | "Output sets this field should be included in; ALL includes the field" |
| 61 | " in all output sets.", |
| 62 | copyable=True) |
| 63 | |
| 64 | def __repr__scip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#__repr__().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#__repr__().(self)): |
| 65 | return "<OutputField %s>"%repr(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#__repr__().(self).name) |
| 66 | |
| 67 | def completeElementscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self), ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(ctx)): |
| 68 | if selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self).restrictedMode and ( |
| 69 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self).formatter |
| 70 | or selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self).selectscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#select.): |
| 71 | raise basescip-python python gavodachs 2.13 `gavo.base`/__init__:.RestrictedElementscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self).name_scip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#name_., hintscip-python python gavodachs 2.13 `gavo.utils.excs`/RestrictedElement#__init__().(hint)="formatter and select" |
| 72 | " attributes on output fields are not allowed in restricted mode.") |
| 73 | if selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self).selectscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#select. is basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Undefinedscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#: |
| 74 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self).selectscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#select. = selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(self).name |
| 75 | superscip-python python python-stdlib 3.11 builtins/super#().completeElementscip-python python gavodachs 2.13 `gavo.base.common`/StructCallbacks#completeElement().(ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#completeElement().(ctx)) |
| 76 | |
| 77 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 78 | def fromColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(clsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(cls), colscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(col)): |
| 79 | res = clsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(cls)(None, **colscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(col).getAttributes(rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.Columnscip-python python gavodachs 2.13 `gavo.base.structure`/Column#)) |
| 80 | res.stc = colscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(col).stc |
| 81 | res.dmRoles = rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.OldRolesscip-python python gavodachs 2.13 `gavo.rscdef.column`/OldRoles#(colscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(col).dmRoles) |
| 82 | return res.finishElement() |
| 83 | |
| 84 | def expandscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#expand().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#expand().(self), *argsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#expand().(args), **kwargsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#expand().(kwargs)): |
| 85 | return selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#expand().(self).parentscip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#parent..expand(*argsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#expand().(args), **kwargsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#expand().(kwargs)) |
| 86 | |
| 87 | |
| 88 | class OutputTableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#(rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.TableDefscip-python python gavodachs 2.13 `gavo.base.structure`/TableDef#): |
| 89 | """A table that has outputFields for columns. |
| 90 | |
| 91 | Cores always have one of these, but they are implicitly defined by |
| 92 | the underlying database tables in case of dbCores and such. |
| 93 | |
| 94 | Services may define output tables to modify what is coming back from |
| 95 | the core. Note that this usually only affects the output to web browsers. |
| 96 | To use the output table also through VO protocols (and when producing |
| 97 | VOTables, FITS files, and the like), you need to set the service's |
| 98 | votableRespectsOutputTable property to True. |
| 99 | """ |
| 100 | name_scip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#name_. = "outputTable" |
| 101 | |
| 102 | # Don't validate meta for these -- while they are children |
| 103 | # of validated structures (services), they don't need any |
| 104 | # meta at all. This should go as soon as we have a sane |
| 105 | # inheritance hierarchy for tables. |
| 106 | metaModelscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#metaModel. = None |
| 107 | |
| 108 | _colsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_cols. = rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.ColumnListAttributescip-python python gavodachs 2.13 `gavo.rscdef.common`/ColumnListAttribute#("columns", |
| 109 | childFactoryscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(childFactory)=OutputFieldscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#, |
| 110 | descriptionscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(description)="Output fields for this table.", |
| 111 | aliases=["column"], |
| 112 | copyable=True) |
| 113 | |
| 114 | _verbLevelscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_verbLevel. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.IntAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("verbLevel", |
| 115 | defaultscip-python python gavodachs 2.13 `gavo.base.attrdef`/AttributeDef#__init__().(default)=None, |
| 116 | descriptionscip-python python gavodachs 2.13 `gavo.base.attrdef`/AttributeDef#__init__().(description)="Copy over columns from fromTable not" |
| 117 | " more verbose than this.") |
| 118 | |
| 119 | _autocolsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_autocols. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StringListAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("autoCols", |
| 120 | description="Column names obtained from fromTable; you can use" |
| 121 | " shell patterns into the output table's parent table (in a table" |
| 122 | " core, that's the queried table; in a service, it's the core's" |
| 123 | " output table) here.") |
| 124 | |
| 125 | def __init__scip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self), parentscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(parent), **kwargsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(kwargs)): |
| 126 | rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.TableDefscip-python python gavodachs 2.13 `gavo.base.structure`/TableDef#.__init__scip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#__init__().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self), parentscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(parent), **kwargsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(kwargs)) |
| 127 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable. = None |
| 128 | try: |
| 129 | # am I in a table-based core? |
| 130 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable. = selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentscip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#parent..queriedTable |
| 131 | except (AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#, basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructureErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#): |
| 132 | # no. |
| 133 | pass |
| 134 | |
| 135 | if not selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable.: |
| 136 | try: |
| 137 | # am I in a service with a core with output table? |
| 138 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable. = selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentscip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#parent..core.outputTable |
| 139 | except (AttributeErrorscip-python python python-stdlib 3.11 builtins/AttributeError#, basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructureErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#): |
| 140 | # no. |
| 141 | pass |
| 142 | |
| 143 | if not selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable.: |
| 144 | # no suitable column source, use an empty table: |
| 145 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable. = _EMPTY_TABLEscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/_EMPTY_TABLE. |
| 146 | |
| 147 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#__init__().(self).namePathscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#namePath. = None |
| 148 | |
| 149 | def _adoptColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(self), sourceColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(sourceColumn)): |
| 150 | # Do not overwrite existing fields here to let the user |
| 151 | # override individually |
| 152 | try: |
| 153 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(self).getColumnByName(sourceColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(sourceColumn).name) |
| 154 | except basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NotFoundErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#: |
| 155 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(self).feedObject("outputField", OutputFieldscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#.fromColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(sourceColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(sourceColumn))) |
| 156 | |
| 157 | def _addNamesscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(self), ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(ctx), namesscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(names)): |
| 158 | # since autoCols is not copyable, we can require |
| 159 | # that _addNames only be called when there's a real parse context. |
| 160 | if ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(ctx) is None: |
| 161 | raise basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructureErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#("outputTable autocols is" |
| 162 | " only available with a parse context") |
| 163 | for name in namesscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(names): |
| 164 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(self)._addNamescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(ctx), name) |
| 165 | |
| 166 | def _addNamescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(self), ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(ctx), namescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(name)): |
| 167 | """adopts a param or column name into the outputTable. |
| 168 | |
| 169 | name may be a reference or a param or column name in the parent |
| 170 | table (as determined in the constructor, i.e., the queried table |
| 171 | of a core or the output table of a service's core. |
| 172 | |
| 173 | You can also use shell patterns into parent columns. |
| 174 | """ |
| 175 | if utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__:.identifierPatternscip-python python gavodachs 2.13 `gavo.utils.texttricks`/identifierPattern..matchscip-python python python-stdlib 3.11 re/Pattern#match().(namescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(name)): |
| 176 | refOb = ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(ctx).resolveId(namescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(name), selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(self)) |
| 177 | if refOb.name_=="param": |
| 178 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(self).feedObject("param", refOb.copy(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(self))) |
| 179 | else: |
| 180 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(self)._adoptColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(refOb) |
| 181 | |
| 182 | else: |
| 183 | # it's a shell pattern into parent table |
| 184 | for col in selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable.: |
| 185 | if fnmatchscip-python python python-stdlib 3.11 fnmatch/__init__:.fnmatchscip-python python python-stdlib 3.11 fnmatch/fnmatch().(col.name, namescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(name)): |
| 186 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addName().(self)._adoptColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(col) |
| 187 | |
| 188 | def completeElementscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self), ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(ctx)): |
| 189 | if selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self).autoCols: |
| 190 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self)._addNamesscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_addNames().(ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(ctx), selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self).autoCols) |
| 191 | |
| 192 | if selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self).verbLevel: |
| 193 | table = selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self).parentTablescip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#parentTable. |
| 194 | for col in table.columns: |
| 195 | if col.verbLevel<=selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self).verbLevel: |
| 196 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self)._adoptColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#_adoptColumn().(col) |
| 197 | for par in table.params: |
| 198 | if par.verbLevel<=selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self).verbLevel: |
| 199 | selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self).feedObject("param", par.copy(selfscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(self))) |
| 200 | |
| 201 | superscip-python python python-stdlib 3.11 builtins/super#().completeElementscip-python python gavodachs 2.13 `gavo.base.common`/StructCallbacks#completeElement().(ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#completeElement().(ctx)) |
| 202 | |
| 203 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 204 | def fromColumnsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromColumns().(clsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromColumns().(cls), columnsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromColumns().(columns), **kwargsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromColumns().(kwargs)): |
| 205 | return rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.TableDefscip-python python gavodachs 2.13 `gavo.base.structure`/TableDef#.fromColumns([OutputFieldscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#.fromColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(c) |
| 206 | for c in columnsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromColumns().(columns)]) |
| 207 | |
| 208 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 209 | def fromTableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(clsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(cls), tableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(tableDef), ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(ctx)=None): |
| 210 | res = clsscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(cls)(None, columns=[OutputFieldscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#.fromColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(c) for c in tableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(tableDef)], |
| 211 | dupePolicy=tableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(tableDef).dupePolicy, |
| 212 | primary=tableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(tableDef).primary, params=tableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(tableDef).params).finishElement(ctxscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(ctx)) |
| 213 | res.copyMetaFrom(tableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#fromTableDef().(tableDef)) |
| 214 | return res |
| 215 | |
| 216 | # TODO: we ought to somewhere have an API like |
| 217 | # |
| 218 | # def getTableForQuery(td, colNames, whereClause, conn): |
| 219 | # oTD = svcs.OutputTable.fromColumns( |
| 220 | # [td.getColumnByName(n) for n in colNames]) |
| 221 | # return rsc.TableForDef(ot, rows |
| 222 | # =conn.queryToDicts(td.getSimpleQuery(oTD, whereClause)) |