| 1 | """ |
| 2 | Services, i.e. combinations of a core and at least one renderer. |
| 3 | |
| 4 | See the __init__.py docstring for a bit more on the general |
| 5 | architecture. |
| 6 | """ |
| 7 | |
| 8 | #c Copyright 2008-2025, the GAVO project <[email protected]> |
| 9 | #c |
| 10 | #c This program is free software, covered by the GNU GPL. See the |
| 11 | #c COPYING file in the source distribution. |
| 12 | |
| 13 | |
| 14 | import functoolsscip-python python python-stdlib 3.11 functools/__init__: |
| 15 | import osscip-python python python-stdlib 3.11 os/__init__: |
| 16 | import urllib.parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__: |
| 17 | |
| 18 | from twisted.web.templatescip-python python gavodachs 2.13 `twisted.web.template`/__init__: import tags as T #noflake: namespace registration |
| 19 | |
| 20 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import basescip-python python gavodachs 2.13 `gavo.base`/__init__: |
| 21 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import rscscip-python python gavodachs 2.13 `gavo.rsc`/__init__: |
| 22 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__: |
| 23 | from gavoscip-python python gavodachs 2.13 gavo/__init__: import utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__: |
| 24 | from gavo.basescip-python python gavodachs 2.13 `gavo.base`/__init__: import metascip-python python gavodachs 2.13 `gavo.base.meta`/__init__: |
| 25 | from gavo.formalscip-python python gavodachs 2.13 `gavo.formal`/__init__: import nevowcscip-python python gavodachs 2.13 nevowc/__init__: |
| 26 | from gavo.rscscip-python python gavodachs 2.13 `gavo.rsc`/__init__: import tablescip-python python gavodachs 2.13 `gavo.rsc.table`/__init__: |
| 27 | from gavo.rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__: import rmkdefscip-python python gavodachs 2.13 `gavo.rscdef.rmkdef`/__init__: |
| 28 | from gavo.svcsscip-python python gavodachs 2.13 `gavo.svcs`/__init__: import commonscip-python python gavodachs 2.13 `gavo.svcs.common`/__init__: |
| 29 | from gavo.svcsscip-python python gavodachs 2.13 `gavo.svcs`/__init__: import corescip-python python gavodachs 2.13 `gavo.svcs.core`/__init__: |
| 30 | from gavo.svcsscip-python python gavodachs 2.13 `gavo.svcs`/__init__: import inputdefscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/__init__: |
| 31 | from gavo.svcsscip-python python gavodachs 2.13 `gavo.svcs`/__init__: import outputdefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/__init__: |
| 32 | from gavo.svcsscip-python python gavodachs 2.13 `gavo.svcs`/__init__: import renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__: |
| 33 | |
| 34 | |
| 35 | MSscip-python python gavodachs 2.13 `gavo.svcs.service`/MS. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct(). |
| 36 | |
| 37 | |
| 38 | class PreparsedInputscip-python python gavodachs 2.13 `gavo.svcs.service`/PreparsedInput#(dictscip-python python python-stdlib 3.11 builtins/dict#): |
| 39 | """a sentinel class signalling to the service that its input already |
| 40 | is parsed. |
| 41 | |
| 42 | This is for for stuff coming from nevow formal rather than request.strargs, |
| 43 | and to be fed into service.run. |
| 44 | |
| 45 | Construct with a dictionary. |
| 46 | """ |
| 47 | |
| 48 | |
| 49 | class Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Structurescip-python python gavodachs 2.13 `gavo.base.structure`/Structure#, basescip-python python gavodachs 2.13 `gavo.base`/__init__:.ComputedMetaMixinscip-python python gavodachs 2.13 `gavo.base.meta`/ComputedMetaMixin#): |
| 50 | """A specification of how a service should be published. |
| 51 | |
| 52 | This contains most of the metadata for what is an interface in |
| 53 | registry speak. |
| 54 | """ |
| 55 | name_scip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#name_. = "publish" |
| 56 | |
| 57 | _rdscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_rd. = rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.RDAttributescip-python python gavodachs 2.13 `gavo.rscdef.common`/RDAttribute#() |
| 58 | _renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_render. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.UnicodeAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("render", default=basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Undefinedscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#, |
| 59 | description="The renderer the publication will point at.", |
| 60 | copyable=True) |
| 61 | _setsscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_sets. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StringSetAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("sets", |
| 62 | description="Comma-separated list of sets this service will be" |
| 63 | " published in. Predefined are: local=publish on front page," |
| 64 | " ivo_managed=register with the VO registry. If you leave it" |
| 65 | " empty, 'local' publication is assumed.", |
| 66 | copyable="True") |
| 67 | _servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_service. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.ReferenceAttributescip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#("service", defaultscip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#__init__().(default)=basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NotGivenscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#, |
| 68 | descriptionscip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#__init__().(description)="Reference for a service actually implementing the" |
| 69 | " capability corresponding to this publication. This is" |
| 70 | " mainly when there is a vs:WebBrowser service accompanying a VO" |
| 71 | " protocol service, and this other service should be published" |
| 72 | " in the same resource record; you would say something like" |
| 73 | ' ``<publish render="form" sets="..." service="web"/>``.', |
| 74 | copyable="True") |
| 75 | _auxiliaryscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_auxiliary. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.BooleanAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("auxiliary", defaultscip-python python gavodachs 2.13 `gavo.base.attrdef`/AttributeDef#__init__().(default)=False, |
| 76 | descriptionscip-python python gavodachs 2.13 `gavo.base.attrdef`/AttributeDef#__init__().(description)="Auxiliary publications are for capabilities" |
| 77 | " not intended to be picked up for all-VO queries, typically" |
| 78 | " because they are already registered with other services." |
| 79 | " This is mostly used internally; you probably have no reason" |
| 80 | " to touch it.") |
| 81 | |
| 82 | def __repr__scip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#__repr__().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#__repr__().(self)): |
| 83 | return "<%sPublication of %s in %s>"%( |
| 84 | "Auxiliary " if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#__repr__().(self).auxiliary else "", |
| 85 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#__repr__().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service..getFullId(), |
| 86 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#__repr__().(self).sets) |
| 87 | |
| 88 | def _completeMetadataFromResRowscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_completeMetadataFromResRow().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_completeMetadataFromResRow().(self), resRowscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_completeMetadataFromResRow().(resRow)): |
| 89 | """fiddles publication dates from a dc.resources row for the parent |
| 90 | service. |
| 91 | |
| 92 | (see rscdef.rdjinj for where this comes from). |
| 93 | """ |
| 94 | if resRowscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_completeMetadataFromResRow().(resRow).get("rectimestamp"): |
| 95 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_completeMetadataFromResRow().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service..setMeta("_metadataUpdated", resRowscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_completeMetadataFromResRow().(resRow)["rectimestamp"]) |
| 96 | # we ignore dateupdated here, assuming that the info coming from |
| 97 | # the RD is more current. |
| 98 | |
| 99 | def completeElementscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self), ctxscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(ctx)): |
| 100 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render. is basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Undefinedscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#: |
| 101 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render. = "form" |
| 102 | if not selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).sets: |
| 103 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).sets.add("local") |
| 104 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service. is basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NotGivenscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#: |
| 105 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service. = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).parentscip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#parent. |
| 106 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).setMetaParentscip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#setMetaParent().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service.) |
| 107 | |
| 108 | if (ctxscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(ctx) is not None |
| 109 | # RD-less services are probably testing-only, and they certainly |
| 110 | # won't be registered. |
| 111 | and selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).rd is not None): |
| 112 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self)._completeMetadataFromResRowscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_completeMetadataFromResRow().( |
| 113 | ctxscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(ctx).getInjectedscip-python python gavodachs 2.13 `gavo.base.parsecontext`/ParseContext#getInjected().("resprop:%s#%s"%( |
| 114 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service..rd.sourceId, selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#completeElement().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service..id), {})) |
| 115 | |
| 116 | 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.service`/Publication#completeElement().(ctx)) |
| 117 | |
| 118 | def validatescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#validate().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#validate().(self)): |
| 119 | superscip-python python python-stdlib 3.11 builtins/super#().validatescip-python python gavodachs 2.13 `gavo.base.common`/StructCallbacks#validate().() |
| 120 | try: |
| 121 | renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#validate().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render.) |
| 122 | except KeyErrorscip-python python python-stdlib 3.11 builtins/KeyError#: |
| 123 | raise basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructureErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#("Unknown renderer: %s"%selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#validate().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render.) |
| 124 | |
| 125 | unknownSets = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#validate().(self).sets-setscip-python python python-stdlib 3.11 builtins/set#(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getConfigscip-python python gavodachs 2.13 `gavo.base.config`/get.("ivoa", "validoaisets")) |
| 126 | if unknownSets: |
| 127 | raise basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructureErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#("Invalid OAI set(s) %s"% |
| 128 | ", ".joinscip-python python python-stdlib 3.11 builtins/str#join().(unknownSets), |
| 129 | hintscip-python python gavodachs 2.13 `gavo.utils.excs`/StructureError#__init__().(hint)="If you really want to use custom sets, declare add them" |
| 130 | " using the [ivoa]validOAISets config item.") |
| 131 | |
| 132 | def _meta_accessURLscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_accessURL().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_accessURL().(self)): |
| 133 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_accessURL().(self).servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#service..getURL(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_accessURL().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render., canonical=True) |
| 134 | |
| 135 | def _meta_urlUsescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_urlUse().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_urlUse().(self)): |
| 136 | return renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_urlUse().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render.).urlUse |
| 137 | |
| 138 | def _meta_requestMethodscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_requestMethod().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_requestMethod().(self)): |
| 139 | return renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_requestMethod().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render.).preferredMethod |
| 140 | |
| 141 | def _meta_resultTypescip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_resultType().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_resultType().(self)): |
| 142 | return renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#_meta_resultType().(self).renderscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#render.).resultType |
| 143 | |
| 144 | |
| 145 | class _inevowFakescip-python python gavodachs 2.13 `gavo.svcs.service`/_inevowFake#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 146 | """A minimal fake for DaCHS1 imp.nevow.inevow. |
| 147 | |
| 148 | DaCHS 1 docs instructed users to get the request object using |
| 149 | inevow.IRequest(ctx). This thing lets people run RDs doing that. |
| 150 | |
| 151 | I guess we won't remove it any time soon -- it's not expensive, and |
| 152 | removing it would probably break quite a few RDs. |
| 153 | """ |
| 154 | @classmethodscip-python python python-stdlib 3.11 builtins/classmethod# |
| 155 | def IRequestscip-python python gavodachs 2.13 `gavo.svcs.service`/_inevowFake#IRequest().(clsscip-python python gavodachs 2.13 `gavo.svcs.service`/_inevowFake#IRequest().(cls), ctxscip-python python gavodachs 2.13 `gavo.svcs.service`/_inevowFake#IRequest().(ctx)): |
| 156 | return ctxscip-python python gavodachs 2.13 `gavo.svcs.service`/_inevowFake#IRequest().(ctx).request |
| 157 | |
| 158 | |
| 159 | class CustomPageFunctionscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Structurescip-python python gavodachs 2.13 `gavo.base.structure`/Structure#, basescip-python python gavodachs 2.13 `gavo.base`/__init__:.RestrictionMixinscip-python python gavodachs 2.13 `gavo.base.structure`/RestrictionMixin#): |
| 160 | """An abstract base for t.w.resource.Resource-related functions on services. |
| 161 | """ |
| 162 | _namescip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#_name. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.UnicodeAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("name", default=basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Undefinedscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#, |
| 163 | description="Name of the render or data function (use this in the" |
| 164 | " n:render or n:data attribute in custom templates).", |
| 165 | copyable=True, strip=True) |
| 166 | _codescip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#_code. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.DataContentscip-python python gavodachs 2.13 `gavo.base.structure`/DataContent#(descriptionscip-python python gavodachs 2.13 `gavo.base.structure`/DataContent#__init__().(description)="Function body of the renderer" |
| 167 | " or data function; the" |
| 168 | " arguments are named ``request`` and ``tag``, but you can also use" |
| 169 | " legacy ctx.tag and ctx.request. If data has been set on a tag," |
| 170 | " you will see it as ``data``.", copyable=True) |
| 171 | |
| 172 | def onElementCompletescip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#onElementComplete().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#onElementComplete().(self)): |
| 173 | superscip-python python python-stdlib 3.11 builtins/super#().onElementCompletescip-python python gavodachs 2.13 `gavo.base.common`/StructCallbacks#onElementComplete().() |
| 174 | vars = globals().copyscip-python python python-stdlib 3.11 builtins/dict#copy().() |
| 175 | vars["service"] = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#onElementComplete().(self).parentscip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#parent. |
| 176 | vars["_FakeContext"] = _FakeContextscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext# |
| 177 | vars["inevow"] = _inevowFakescip-python python gavodachs 2.13 `gavo.svcs.service`/_inevowFake# |
| 178 | exec("\n".joinscip-python python python-stdlib 3.11 builtins/str#join().([ |
| 179 | "def %s(self, request, tag):"%(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#onElementComplete().(self).name), |
| 180 | " ctx = _FakeContext(tag, request)", |
| 181 | " data = tag.slotData", |
| 182 | utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__:.fixIndentationscip-python python gavodachs 2.13 `gavo.utils.texttricks`/fixIndentation().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#onElementComplete().(self).content_, newIndentscip-python python gavodachs 2.13 `gavo.utils.texttricks`/fixIndentation().(newIndent)=" ", |
| 183 | governingLinescip-python python gavodachs 2.13 `gavo.utils.texttricks`/fixIndentation().(governingLine)=1).rstripscip-python python python-stdlib 3.11 builtins/str#rstrip().()]), vars) |
| 184 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#onElementComplete().(self).funcscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#func. = vars[selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#onElementComplete().(self).name] |
| 185 | |
| 186 | |
| 187 | class _FakeContextscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#(objectscip-python python python-stdlib 3.11 builtins/object#): |
| 188 | """A compatibility wrapper for legacy nevow contexts. |
| 189 | |
| 190 | These don't exist any more, but I didn't want to break all custom |
| 191 | render and data functions in RDs, so I fake enough to give people |
| 192 | the standard ctx.tag. There's even a fake invevow above that's just |
| 193 | enough to pull the request from here. |
| 194 | """ |
| 195 | def __init__scip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(self), tagscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(tag), requestscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(request)): |
| 196 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(self).tagscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#tag., selfscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(self).requestscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#request. = tagscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(tag), requestscip-python python gavodachs 2.13 `gavo.svcs.service`/_FakeContext#__init__().(request) |
| 197 | |
| 198 | |
| 199 | class CustomRFscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomRF#(CustomPageFunctionscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#): |
| 200 | """A custom render function for a service. |
| 201 | |
| 202 | Custom render functions can be used to expose certain aspects of a service |
| 203 | to Nevow templates. Thus, their definition usually only makes sense with |
| 204 | custom templates, though you could, in principle, override built-in |
| 205 | render functions. |
| 206 | |
| 207 | In the render functions, you have the names ctx for a context and |
| 208 | data for the "current data" (i.e., what's last been set using n:data). |
| 209 | In ctx, only use ctx.tag (the tag on which the n:render attribute |
| 210 | sits) and, if necessary ctx.request (the t.w request object). |
| 211 | |
| 212 | Also, the active renderer is visible as self; the one thing you |
| 213 | might want to see from there is self.queryMeta, which contains, |
| 214 | for instance, the input parameters (but be careful: the inputTable |
| 215 | will be None when input errors are rendered, so it is better to write |
| 216 | something like:: |
| 217 | |
| 218 | if self.queryMeta["inputTable"] and self.queryMeta["inputTable"]...: |
| 219 | |
| 220 | You can return anything that can be in a stan DOM. Usually, this will be |
| 221 | a string. To return HTML, use the stan DOM available under the T namespace. |
| 222 | |
| 223 | As an example, the following code returns the current data as a link:: |
| 224 | |
| 225 | return ctx.tag[T.a(href=data)[data]] |
| 226 | |
| 227 | You can access the embedding service as service, the embedding |
| 228 | RD as service.rd. |
| 229 | """ |
| 230 | name_scip-python python gavodachs 2.13 `gavo.svcs.service`/CustomRF#name_. = "customRF" |
| 231 | |
| 232 | |
| 233 | class CustomDFscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomDF#(CustomPageFunctionscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomPageFunction#): |
| 234 | """A custom data function for a service. |
| 235 | |
| 236 | Custom data functions can be used to expose certain aspects of a service |
| 237 | to Nevow templates. Thus, their definition usually only makes sense with |
| 238 | custom templates, though you could, in principle, override built-in |
| 239 | render functions. |
| 240 | |
| 241 | In the data functions, you have the names ctx for a context and |
| 242 | data for the "current data" (i.e., what's last been set using n:data). |
| 243 | In ctx, only use ctx.tag (the tag on which the n:render attribute |
| 244 | sits) and, if necessary ctx.request (the t.w request object). |
| 245 | |
| 246 | Also, the active renderer is visible as self; the one thing you |
| 247 | might want to see from there is self.queryMeta, which contains, |
| 248 | for instance, the input parameters. |
| 249 | |
| 250 | |
| 251 | You can access the embedding service as service, the embedding |
| 252 | RD as service.rd. |
| 253 | |
| 254 | You can return arbitrary python objects -- whatever the render functions |
| 255 | can deal with. You could, e.g., write:: |
| 256 | |
| 257 | <customDF name="now"> |
| 258 | return datetime.datetime.utcnow() |
| 259 | </customDF> |
| 260 | |
| 261 | You can use the request to fetch request parameters. Within DaCHS, |
| 262 | in addition to the clumsy request.args (mapping bytes to bytes), there |
| 263 | is also request.strargs (mapping strings to strings). So, access a |
| 264 | query parameter ``order`` like this:: |
| 265 | |
| 266 | sortOrder = ctx.request.strargs.get("order", ["authors"]) |
| 267 | """ |
| 268 | name_scip-python python gavodachs 2.13 `gavo.svcs.service`/CustomDF#name_. = "customDF" |
| 269 | |
| 270 | |
| 271 | class CoreAttributescip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.ReferenceAttributescip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#): |
| 272 | def __init__scip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#__init__().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#__init__().(self)): |
| 273 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.ReferenceAttributescip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#.__init__scip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#__init__().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#__init__().(self), "core", |
| 274 | descriptionscip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#__init__().(description)="The core that does the computations for this service." |
| 275 | " Instead of a reference, you can use an immediate element" |
| 276 | " of some registered core.", |
| 277 | forceTypescip-python python gavodachs 2.13 `gavo.base.parsecontext`/ReferenceAttribute#__init__().(forceType)=corescip-python python gavodachs 2.13 `gavo.svcs.core`/__init__:.Corescip-python python gavodachs 2.13 `gavo.svcs.core`/Core#, copyable=True, aliases=listscip-python python python-stdlib 3.11 builtins/list#(corescip-python python gavodachs 2.13 `gavo.svcs.core`/__init__:.CORE_REGISTRYscip-python python gavodachs 2.13 `gavo.svcs.core`/CORE_REGISTRY..keysscip-python python python-stdlib 3.11 builtins/dict#keys().())) |
| 278 | |
| 279 | def _makeChildscip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#_makeChild().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#_makeChild().(self), namescip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#_makeChild().(name), parentscip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#_makeChild().(parent)): |
| 280 | return corescip-python python gavodachs 2.13 `gavo.svcs.core`/__init__:.getCorescip-python python gavodachs 2.13 `gavo.svcs.core`/getCore().(namescip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#_makeChild().(name))(parentscip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#_makeChild().(parent)) |
| 281 | |
| 282 | |
| 283 | @functoolsscip-python python python-stdlib 3.11 functools/__init__:.lru_cachescip-python python python-stdlib 3.11 functools/lru_cache().(1) |
| 284 | def getDALIServiceKeysscip-python python gavodachs 2.13 `gavo.svcs.service`/getDALIServiceKeys().(): |
| 285 | """returns a list of the service keys defined in //pql#DALIPars. |
| 286 | |
| 287 | This is always the same object, so if you really have to change anything |
| 288 | in here, be sure to make copies before touching either the list or |
| 289 | the items. |
| 290 | """ |
| 291 | nullSvc = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.parseFromStringscip-python python gavodachs 2.13 `gavo.base.xmlstruct`/parseFromString().(Servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#, |
| 292 | """<service><nullCore/><FEED source="//pql#DALIPars"/></service>""") |
| 293 | |
| 294 | res = [] |
| 295 | for inputKey in nullSvc.serviceKeys: |
| 296 | # let's orphan them in a way that they won't be reparented |
| 297 | inputKey.parent_ = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NotGivenscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute# |
| 298 | res.appendscip-python python python-stdlib 3.11 builtins/list#append().(inputKey) |
| 299 | |
| 300 | return res |
| 301 | |
| 302 | |
| 303 | class GetURLMixinscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#: |
| 304 | """A mixin for classes with rd and id, letting them compute |
| 305 | URLs working with the DaCHS root.py URL dispatcher. |
| 306 | """ |
| 307 | def getURLscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(self), rendNamescip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(rendName), absolutescip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(absolute)=True, canonicalscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(canonical)=False, **kwargsscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(kwargs)): |
| 308 | """returns the full canonical access URL of this service together |
| 309 | with renderer. |
| 310 | |
| 311 | rendName is the name of the intended renderer in the registry |
| 312 | of renderers. |
| 313 | |
| 314 | With absolute, a fully qualified URL is being returned. |
| 315 | |
| 316 | Further keyword arguments are translated into URL parameters in the |
| 317 | query part. |
| 318 | """ |
| 319 | basePath = "%s%s/%s"%(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getConfigscip-python python gavodachs 2.13 `gavo.base.config`/get.("web", "nevowRoot"), |
| 320 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(self).rd.sourceId, selfscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(self).id) |
| 321 | if absolutescip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(absolute): |
| 322 | basePath = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeAbsoluteURL(basePath, canonical=canonicalscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(canonical)) |
| 323 | res = renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(rendNamescip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(rendName) |
| 324 | ).makeAccessURL(basePath) |
| 325 | |
| 326 | if kwargsscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(kwargs): |
| 327 | res = res+"?"+urllib.parsescip-python python python-stdlib 3.11 `urllib.parse`/__init__:.urlencode(kwargsscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(kwargs)) |
| 328 | return res |
| 329 | |
| 330 | |
| 331 | class Servicescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Structurescip-python python gavodachs 2.13 `gavo.base.structure`/Structure#, basescip-python python gavodachs 2.13 `gavo.base`/__init__:.ComputedMetaMixinscip-python python gavodachs 2.13 `gavo.base.meta`/ComputedMetaMixin#, |
| 332 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StandardMacroMixinscip-python python gavodachs 2.13 `gavo.base.macros`/StandardMacroMixin#, rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.IVOMetaMixinscip-python python gavodachs 2.13 `gavo.rscdef.common`/IVOMetaMixin#, |
| 333 | GetURLMixinscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#): |
| 334 | """A service definition. |
| 335 | |
| 336 | A service is a combination of a core and one or more renderers. They |
| 337 | can be published, and they carry the metadata published into the VO. |
| 338 | |
| 339 | |
| 340 | Properties evaluated: |
| 341 | |
| 342 | * votableRespectsOutputTable -- usually, VOTable output puts in |
| 343 | all columns from the underlying database table with low enough |
| 344 | verbLevel (essentially). When this property is "True" (case-sensitive), |
| 345 | that's not done and only the service's output table is evaluated. |
| 346 | * fixedFormat -- if this is set to "True", the form renderer will |
| 347 | not produce an output format selector (and we shouldn't produce |
| 348 | DALI RESPONSEFORMAT metadata). |
| 349 | * publishedRenderers -- when you publish an entire RD, use these |
| 350 | (comma-separated) renderers to create capabilities from this service |
| 351 | rather than what's in allowed. Set it to empty to hide the service |
| 352 | entirely. |
| 353 | * defaultSort -- this is a name of a database column and preselects a sort |
| 354 | order. Note again that this will slow down responses for all but the |
| 355 | smallest tables unless there is an index on that column. |
| 356 | """ |
| 357 | name_scip-python python gavodachs 2.13 `gavo.svcs.service`/Service#name_. = "service" |
| 358 | |
| 359 | _corescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_core. = CoreAttributescip-python python gavodachs 2.13 `gavo.svcs.service`/CoreAttribute#() |
| 360 | _templatesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_templates. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.DictAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#("templates", descriptionscip-python python gavodachs 2.13 `gavo.base.complexattrs`/DictAttribute#__init__().(description)="Custom" |
| 361 | ' nevow templates for this service; use key "form" to replace the Form' |
| 362 | " renderer's standard template; qp uses resulttable and resultline" |
| 363 | " depending on whether there's many result lines or just one." |
| 364 | " Start the path with two slashes to access system templates.", |
| 365 | aliases=["template"], |
| 366 | itemAttDscip-python python gavodachs 2.13 `gavo.base.complexattrs`/DictAttribute#__init__().(itemAttD)=rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.ResdirRelativeAttributescip-python python gavodachs 2.13 `gavo.rscdef.common`/ResdirRelativeAttribute#( |
| 367 | "template", descriptionscip-python python gavodachs 2.13 `gavo.rscdef.common`/ResdirRelativeAttribute#__init__().(description)="resdir-relative path to a nevow template" |
| 368 | " used for the function given in key."), copyable=True) |
| 369 | _publicationsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_publications. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructListAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#("publications", |
| 370 | childFactoryscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(childFactory)=Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, descriptionscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(description)="Sets and renderers this service" |
| 371 | " is published with.") |
| 372 | _limitToscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_limitTo. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.UnicodeAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("limitTo", default=None, |
| 373 | description="Limit access to the group given; the empty default disables" |
| 374 | " access control.", copyable="True") |
| 375 | _customPagescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_customPage. = rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.ResdirRelativeAttributescip-python python gavodachs 2.13 `gavo.rscdef.common`/ResdirRelativeAttribute#("customPage", defaultscip-python python gavodachs 2.13 `gavo.rscdef.common`/ResdirRelativeAttribute#__init__().(default)=None, |
| 376 | descriptionscip-python python gavodachs 2.13 `gavo.rscdef.common`/ResdirRelativeAttribute#__init__().(description)="resdir-relative path to custom page code. It is used" |
| 377 | " by the 'custom' renderer", copyable="True") |
| 378 | _allowedRenderersscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_allowedRenderers. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StringSetAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("allowed", |
| 379 | description="Names of renderers allowed on this service; leave empty" |
| 380 | " to allow the form renderer only.", copyable=True) |
| 381 | _customRFscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_customRF. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructListAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#("customRFs", |
| 382 | descriptionscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(description)="Custom render functions for use in custom templates.", |
| 383 | childFactoryscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(childFactory)=CustomRFscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomRF#, copyable=True) |
| 384 | _customDFscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_customDF. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructListAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#("customDFs", |
| 385 | descriptionscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(description)="Custom data functions for use in custom templates.", |
| 386 | childFactoryscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#__init__().(childFactory)=CustomDFscip-python python gavodachs 2.13 `gavo.svcs.service`/CustomDF#, copyable=True) |
| 387 | _outputTablescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_outputTable. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#("outputTable", defaultscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructAttribute#__init__().(default)=None, |
| 388 | childFactoryscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructAttribute#__init__().(childFactory)=outputdefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/__init__:.OutputTableDefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputTableDef#, copyable=True, descriptionscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructAttribute#__init__().(description)= |
| 389 | "The output fields of this service.") |
| 390 | _serviceKeysscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_serviceKeys. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.UniquedStructListAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#("serviceKeys", |
| 391 | uniqueAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/UniquedStructListAttribute#__init__().(uniqueAttribute)="name", policyscip-python python gavodachs 2.13 `gavo.base.complexattrs`/UniquedStructListAttribute#__init__().(policy)="drop", |
| 392 | childFactoryscip-python python gavodachs 2.13 `gavo.base.complexattrs`/UniquedStructListAttribute#__init__().(childFactory)=inputdefscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/__init__:.InputKeyscip-python python gavodachs 2.13 `gavo.base.structure`/InputKey#, description="Input widgets for" |
| 393 | " processing by the service, e.g. output sets.", copyable=True) |
| 394 | _defaultRendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_defaultRenderer. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.UnicodeAttributescip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("defaultRenderer", |
| 395 | default=None, description="A name of a renderer used when" |
| 396 | " none is provided in the URL (lets you have shorter URLs).") |
| 397 | |
| 398 | _rdscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_rd. = rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.RDAttributescip-python python gavodachs 2.13 `gavo.rscdef.common`/RDAttribute#() |
| 399 | _propsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_props. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.PropertyAttributescip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#() |
| 400 | _originalscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_original. = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.OriginalAttributescip-python python gavodachs 2.13 `gavo.base.parsecontext`/OriginalAttribute#() |
| 401 | |
| 402 | metaModelscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#metaModel. = ("title(1), creationDate(1), description(1)," |
| 403 | " subject, referenceURL(1), shortName(!)," |
| 404 | " productTypeServed(? voc:product-type)," |
| 405 | " dataSource(? voc:data-source)," |
| 406 | " contentLevel(? voc:voresource/content_level)") |
| 407 | |
| 408 | # formats that should query the same fields as HTML (the others behave |
| 409 | # like VOTables and offer a "verbosity" widget in forms). |
| 410 | htmlLikeFormatsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#htmlLikeFormats. = ["HTML", "tar"] |
| 411 | |
| 412 | ####################### Housekeeping methods |
| 413 | |
| 414 | def __repr__scip-python python gavodachs 2.13 `gavo.svcs.service`/Service#__repr__().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#__repr__().(self)): |
| 415 | return "<Service %s at %s>"%(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#__repr__().(self).id, selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#__repr__().(self).getSourcePositionscip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#getSourcePosition().()) |
| 416 | |
| 417 | def completeElementscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self), ctxscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(ctx)): |
| 418 | 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.service`/Service#completeElement().(ctx)) |
| 419 | if not selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).allowed: |
| 420 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).allowed.add("form") |
| 421 | |
| 422 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).core is basescip-python python gavodachs 2.13 `gavo.base`/__init__:.Undefinedscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#: |
| 423 | raise basescip-python python gavodachs 2.13 `gavo.base`/__init__:.StructureErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#("Services must have cores (add <nullCore/>" |
| 424 | " if you really do not want a core, e.g., with fixed renderers).") |
| 425 | |
| 426 | # if there's only one renderer on this service, make it the default |
| 427 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).defaultRendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#defaultRenderer. is None and len(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).allowed)==1: |
| 428 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).defaultRendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#defaultRenderer. = listscip-python python python-stdlib 3.11 builtins/list#(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).allowed)[0] |
| 429 | |
| 430 | # if there's a DALI-compliant renderer on this service, declare |
| 431 | # its service parameters (MAXREC, RESPONSEFORMAT, etc). |
| 432 | # Of course, other renderers might ignore them, but presumably |
| 433 | # the metadata generated from this are only really evaluated |
| 434 | # by VO/DALI components. |
| 435 | # "DALI-complicance" is currently determined by a parameter |
| 436 | # style of dali or pql. |
| 437 | for rendName in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).allowed: |
| 438 | try: |
| 439 | ps = renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(rendName).parameterStyle |
| 440 | except basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NotFoundErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#: |
| 441 | # letting this exc through could lead to confusing error messages |
| 442 | # on cross-RD reference, so we just warn: |
| 443 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.uiscip-python python gavodachs 2.13 `gavo.base`/ui..notifyWarningscip-python python gavodachs 2.13 `gavo.base.events`/EventDispatcher#notifyWarning().("Invalid renderer spec '%s' on service at %s"% |
| 444 | (rendName, selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self).getSourcePositionscip-python python gavodachs 2.13 `gavo.base.structure`/StructureBase#getSourcePosition().())) |
| 445 | continue |
| 446 | |
| 447 | if ps in ["dali", "pql"]: |
| 448 | for inputKey in getDALIServiceKeysscip-python python gavodachs 2.13 `gavo.svcs.service`/getDALIServiceKeys().(): |
| 449 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self)._serviceKeysscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_serviceKeys..addStructscip-python python gavodachs 2.13 `gavo.base.complexattrs`/UniquedStructListAttribute#addStruct().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self), inputKey) |
| 450 | break |
| 451 | |
| 452 | # cache all kinds of things expensive to create and parse |
| 453 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self)._coresCachescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_coresCache. = {} |
| 454 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self)._loadedTemplatesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_loadedTemplates. = {} |
| 455 | |
| 456 | # Schedule the capabilities to be added when the parse is |
| 457 | # done (i.e., the RD is complete) |
| 458 | ctxscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(ctx).addExitFuncscip-python python gavodachs 2.13 `gavo.base.parsecontext`/ParseContext#addExitFunc().(lambda rd, ctx: selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#completeElement().(self)._addAutomaticCapabilitiesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().()) |
| 459 | |
| 460 | def onElementCompletescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self)): |
| 461 | superscip-python python python-stdlib 3.11 builtins/super#().onElementCompletescip-python python gavodachs 2.13 `gavo.base.common`/StructCallbacks#onElementComplete().() |
| 462 | |
| 463 | # Index custom render/data functions |
| 464 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).nevowRenderersscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#nevowRenderers. = {} |
| 465 | for customRF in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).customRFs: |
| 466 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).nevowRenderersscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#nevowRenderers.[customRF.name] = customRF.func |
| 467 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).nevowDataFunctionsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#nevowDataFunctions. = {} |
| 468 | for customDF in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).customDFs: |
| 469 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).nevowDataFunctionsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#nevowDataFunctions.[customDF.name] = customDF.func |
| 470 | |
| 471 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self)._compileCustomPagescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().() |
| 472 | |
| 473 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self)._computeResourceTypescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_computeResourceType().() |
| 474 | |
| 475 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).core, "queriedTable"): |
| 476 | # Copy over any served-by relationships from our table if |
| 477 | # we query one. This is important, for instance, for |
| 478 | # obscore-published tables, where we want to let our |
| 479 | # clients know they could be using obscore instead. |
| 480 | for m in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).core.queriedTable.iterMeta("isServedBy"): |
| 481 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#onElementComplete().(self).addMetascip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#addMeta().("isServedBy", m) |
| 482 | |
| 483 | |
| 484 | def _compileCustomPagescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(self)): |
| 485 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(self).customPage: |
| 486 | try: |
| 487 | modNs, moddesc = utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__:.loadPythonModule(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(self).customPage) |
| 488 | modNs.RD = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(self).rd |
| 489 | getattrscip-python python python-stdlib 3.11 builtins/getattr().(modNs, "initModule", lambda: None)() |
| 490 | page = modNs.MainPage |
| 491 | except ImportErrorscip-python python python-stdlib 3.11 builtins/ImportError#: |
| 492 | raise basescip-python python gavodachs 2.13 `gavo.base`/__init__:.uiscip-python python gavodachs 2.13 `gavo.base`/ui..logOldExcscip-python python gavodachs 2.13 `gavo.base.events`/EventDispatcher#logOldExc().( |
| 493 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.LiteralParseErrorscip-python python gavodachs 2.13 `gavo.base.attrdef`/UnicodeAttribute#("customPage", selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(self).customPage, |
| 494 | hintscip-python python gavodachs 2.13 `gavo.utils.excs`/LiteralParseError#__init__().(hint)="This means that an exception was raised while DaCHS" |
| 495 | " tried to import the renderer module. If DaCHS ran" |
| 496 | " with --debug, the original traceback is available" |
| 497 | " in the logs.")) |
| 498 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(self).customPageCodescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#customPageCode. = page, (osscip-python python python-stdlib 3.11 os/__init__:.pathscip-python python python-stdlib 3.11 os/path..basenamescip-python python python-stdlib 3.11 ntpath/join().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_compileCustomPage().(self).customPage),moddesc) |
| 499 | |
| 500 | def getTemplatescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(self), keyscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(key), reloadscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(reload)=False): |
| 501 | """returns the nevow template for the function key on this service. |
| 502 | |
| 503 | Pass reload to force a reload of templates already parsed. |
| 504 | """ |
| 505 | if reloadscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(reload) or keyscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(key) not in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(self)._loadedTemplatesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_loadedTemplates.: |
| 506 | tp = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(self).templates[keyscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(key)] |
| 507 | if tp.startswith("//"): |
| 508 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(self)._loadedTemplatesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_loadedTemplates.[keyscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(key)] = commonscip-python python gavodachs 2.13 `gavo.svcs.common`/__init__:.loadSystemTemplatescip-python python gavodachs 2.13 `gavo.svcs.common`/loadSystemTemplate().(tp[2:]) |
| 509 | else: |
| 510 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(self)._loadedTemplatesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_loadedTemplates.[keyscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(key)] = nevowcscip-python python gavodachs 2.13 nevowc/__init__:.XMLFilescip-python python gavodachs 2.13 `gavo.formal.nevowc`/XMLFile#( |
| 511 | osscip-python python python-stdlib 3.11 os/__init__:.pathscip-python python python-stdlib 3.11 os/path..joinscip-python python python-stdlib 3.11 ntpath/join().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(self).rd.resdir, tp)) |
| 512 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(self)._loadedTemplatesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_loadedTemplates.[keyscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTemplate().(key)] |
| 513 | |
| 514 | def getUWSscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self)): |
| 515 | """returns the UWS worker system for this service. |
| 516 | |
| 517 | This is a service for the DALIAsyncRenderer. |
| 518 | """ |
| 519 | if not hasattr(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self), "uws"): |
| 520 | if hasattr(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self).core, "workerSystem"): |
| 521 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self).uwsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#uws. = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self).core.workerSystem |
| 522 | else: |
| 523 | # todo: we don't want that any more. People wanting user UWS |
| 524 | # should attach their worker systems to their cores in the future. |
| 525 | from gavo.protocolsscip-python python gavodachs 2.13 `gavo.protocols`/__init__: import useruwsscip-python python gavodachs 2.13 `gavo.protocols.useruws`/__init__: |
| 526 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self).uwsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#uws. = useruwsscip-python python gavodachs 2.13 `gavo.protocols.useruws`/__init__:.makeUWSForServicescip-python python gavodachs 2.13 `gavo.protocols.useruws`/makeUWSForService().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self)) |
| 527 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getUWS().(self).uwsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#uws. |
| 528 | |
| 529 | ################### Registry and related methods. |
| 530 | |
| 531 | @propertyscip-python python python-stdlib 3.11 builtins/property# |
| 532 | def isVOPublishedscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isVOPublished().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isVOPublished().(self), rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isVOPublished().(renderer)=None): |
| 533 | """is true if there is any ivo_managed publication on this |
| 534 | service. |
| 535 | |
| 536 | If renderer is non-None, only publications with this renderer name |
| 537 | count. |
| 538 | """ |
| 539 | for pub in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isVOPublished().(self).publications: |
| 540 | if "ivo_managed" in pub.sets: |
| 541 | if rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isVOPublished().(renderer): |
| 542 | if pub.render==rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isVOPublished().(renderer): |
| 543 | return True |
| 544 | else: |
| 545 | return True |
| 546 | return False |
| 547 | |
| 548 | def _computeResourceTypescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_computeResourceType().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_computeResourceType().(self)): |
| 549 | """sets the resType attribute. |
| 550 | |
| 551 | Services are resources, and the registry code wants to know what kind. |
| 552 | This method ventures a guess. You can override this decision by setting |
| 553 | the resType meta item. |
| 554 | """ |
| 555 | if (selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_computeResourceType().(self).core.outputTable.columns |
| 556 | or "dali" in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_computeResourceType().(self).allowed): |
| 557 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_computeResourceType().(self).resTypescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#resType. = "catalogService" |
| 558 | else: # no output table defined, we're a plain service |
| 559 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_computeResourceType().(self).resTypescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#resType. = "dataService" |
| 560 | |
| 561 | def _iterAutomaticCapabilitiesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self)): |
| 562 | """helps _addAutomaticCapabilities. |
| 563 | |
| 564 | Actually, we also use it to generate VOSI capabilities for |
| 565 | unpublished services. |
| 566 | """ |
| 567 | vosiSet = setscip-python python python-stdlib 3.11 builtins/set#(["ivo_managed"]) |
| 568 | |
| 569 | # Let's give everything a capability, even null cores. |
| 570 | yield basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 571 | render="capabilities", |
| 572 | sets=vosiSet, |
| 573 | parent_=selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self)) |
| 574 | |
| 575 | # If it has a core, there is tables involved, and we do VOSI tables, too |
| 576 | if not isinstance(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self).core, corescip-python python gavodachs 2.13 `gavo.svcs.core`/__init__:.getCorescip-python python gavodachs 2.13 `gavo.svcs.core`/getCore().("nullCore")): |
| 577 | yield basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 578 | render="availability", |
| 579 | sets=vosiSet, |
| 580 | parent_=selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self)) |
| 581 | yield basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 582 | render="tableMetadata", |
| 583 | sets=vosiSet, |
| 584 | parent_=selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self)) |
| 585 | |
| 586 | # things querying tables get a TAP relationship if |
| 587 | # their table is adql-queriable |
| 588 | if isinstance(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self).core, corescip-python python gavodachs 2.13 `gavo.svcs.core`/__init__:.getCorescip-python python gavodachs 2.13 `gavo.svcs.core`/getCore().("dbCore")): |
| 589 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self).core.queriedTable.adql: |
| 590 | tapService = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.resolveCrossIdscip-python python gavodachs 2.13 `gavo.base.parsecontext`/resolveCrossId().("//tap#run") |
| 591 | yield basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 592 | render="dali", |
| 593 | sets=vosiSet, |
| 594 | auxiliary=True, |
| 595 | service=tapService, |
| 596 | parent_=selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self)) |
| 597 | |
| 598 | # things with examples meta get an examples capability |
| 599 | try: |
| 600 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self).getMetascip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#getMeta().("_example", raiseOnFailscip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#getMeta().(raiseOnFail)=True) |
| 601 | yield basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 602 | render="examples", |
| 603 | sets=utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__:.AllEncompassingSetscip-python python gavodachs 2.13 `gavo.utils.codetricks`/AllEncompassingSet#(), |
| 604 | parent_=selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(self)) |
| 605 | except basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NoMetaKeyscip-python python gavodachs 2.13 `gavo.base.meta`/NoMetaKey#: |
| 606 | pass |
| 607 | |
| 608 | def _addAutomaticCapabilitiesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self)): |
| 609 | """adds some publications that are automatic for certain types |
| 610 | of services. |
| 611 | |
| 612 | For services with ivo_managed publications and with useful cores |
| 613 | (this keeps out doc-like publications, which shouldn't have VOSI |
| 614 | resources), artificial VOSI publications are added. |
| 615 | |
| 616 | If there is _example meta, an examples publication is added. |
| 617 | |
| 618 | If this service exposes a table (i.e., a DbCore with a queriedTable) |
| 619 | and that table is adql-readable, also add an auxiliary TAP publication |
| 620 | if going to the VO. |
| 621 | |
| 622 | This is being run as an exit function from the parse context as |
| 623 | we want the RD to be complete at this point (e.g., _examples |
| 624 | meta might come from it). This also lets us liberally resolve |
| 625 | references anywhere. |
| 626 | """ |
| 627 | if not selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self).isVOPublishedscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isVOPublished().: |
| 628 | return |
| 629 | |
| 630 | for pub in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self)._iterAutomaticCapabilitiesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(): |
| 631 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self)._publicationsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_publications..feedObjectscip-python python gavodachs 2.13 `gavo.base.complexattrs`/StructListAttribute#feedObject().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self), pub) |
| 632 | |
| 633 | # This is no longer a good place to do this, but TAP-published |
| 634 | # tables need a isServedBy, and we since it's automatic, let's |
| 635 | # do it here. |
| 636 | # According to the "discovering dependent" note, we don't |
| 637 | # do the reverse relationship lest the TAP service |
| 638 | # gets too related... |
| 639 | if isinstance(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self).core, corescip-python python gavodachs 2.13 `gavo.svcs.core`/__init__:.getCorescip-python python gavodachs 2.13 `gavo.svcs.core`/getCore().("dbCore")): |
| 640 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self).core.queriedTable.adql: |
| 641 | tapService = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.resolveCrossIdscip-python python gavodachs 2.13 `gavo.base.parsecontext`/resolveCrossId().("//tap#run") |
| 642 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_addAutomaticCapabilities().(self).addMetascip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#addMeta().("isServedBy", |
| 643 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getMetaTextscip-python python gavodachs 2.13 `gavo.base.meta`/getMetaText().(tapService, "title"), |
| 644 | ivoId=basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getMetaTextscip-python python gavodachs 2.13 `gavo.base.meta`/getMetaText().(tapService, "identifier")) |
| 645 | |
| 646 | def _iterAssociatedDatalinkServicesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAssociatedDatalinkServices().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAssociatedDatalinkServices().(self)): |
| 647 | """yields instances for datalink services appropriate for this |
| 648 | service. |
| 649 | |
| 650 | The datalink services are taken from the core's queriedTable |
| 651 | attribute, if available. As a legacy fallback, for now |
| 652 | the datalink property on the service is supported as well for now, |
| 653 | but I'll try to get rid of that. |
| 654 | """ |
| 655 | queriedTable = getattrscip-python python python-stdlib 3.11 builtins/getattr().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAssociatedDatalinkServices().(self).core, "queriedTable", None) |
| 656 | # if there's not queried table, there's not much point in |
| 657 | # having a datalink service. |
| 658 | linkGenerated = False |
| 659 | if queriedTable: |
| 660 | for svcRef in queriedTable.iterMeta( |
| 661 | "_associatedDatalinkService.serviceId"): |
| 662 | yield basescip-python python gavodachs 2.13 `gavo.base`/__init__:.resolveIdscip-python python gavodachs 2.13 `gavo.base.parsecontext`/resolveId().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAssociatedDatalinkServices().(self).rd, strscip-python python python-stdlib 3.11 builtins/str#(svcRef)) |
| 663 | linkGenerated = True |
| 664 | |
| 665 | # Legacy fallback in case no datalink services are found in the table: |
| 666 | # the datalink property |
| 667 | if not linkGenerated: |
| 668 | svcRef = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAssociatedDatalinkServices().(self).getProperty("datalink", None) |
| 669 | if svcRef: |
| 670 | yield selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAssociatedDatalinkServices().(self).rd.getById(svcRef) |
| 671 | |
| 672 | def getPublicationsForSetscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(self), namesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(names), includeDatalinkscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(includeDatalink)=True): |
| 673 | """returns publications for a set of set names (the names argument). |
| 674 | |
| 675 | In the special case names=None, all allowed renderers are treated |
| 676 | as published. |
| 677 | """ |
| 678 | addAllAllowed = False |
| 679 | if namesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(names) is None: |
| 680 | namesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(names) = utilsscip-python python gavodachs 2.13 `gavo.utils`/__init__:.AllEncompassingSetscip-python python gavodachs 2.13 `gavo.utils.codetricks`/AllEncompassingSet#() |
| 681 | addAllAllowed = True |
| 682 | |
| 683 | # the or in the list comprehension is because I can't see a way |
| 684 | # to make AllEmcompassingSet work on the right side of the |
| 685 | # operand, but it can occur on both sides. |
| 686 | result = [pub for pub in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(self).publications |
| 687 | if pub.sets & namesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(names) or namesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(names) & pub.sets] |
| 688 | |
| 689 | # for ivo_managed, also return a datalink endpoints if they're |
| 690 | # there; the specs imply that might be useful some day. |
| 691 | # (btw., I think we shouldn't do that but instead extend |
| 692 | # publish so people can ask for other services to be included |
| 693 | # as capabilities). |
| 694 | if includeDatalinkscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(includeDatalink) and "ivo_managed" in namesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(names): |
| 695 | for dlSvc in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(self)._iterAssociatedDatalinkServicesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAssociatedDatalinkServices().(): |
| 696 | if "dlget" in dlSvc.allowed: |
| 697 | result.appendscip-python python python-stdlib 3.11 builtins/list#append().(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 698 | render="dlget", |
| 699 | sets=setscip-python python python-stdlib 3.11 builtins/set#(["ivo_managed"]), |
| 700 | service=dlSvc)) |
| 701 | |
| 702 | if "dlasync" in dlSvc.allowed: |
| 703 | result.appendscip-python python python-stdlib 3.11 builtins/list#append().(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 704 | render="dlasync", |
| 705 | sets=setscip-python python python-stdlib 3.11 builtins/set#(["ivo_managed"]), |
| 706 | service=dlSvc)) |
| 707 | |
| 708 | if "dlmeta" in dlSvc.allowed: |
| 709 | result.appendscip-python python python-stdlib 3.11 builtins/list#append().(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 710 | render="dlmeta", |
| 711 | sets=setscip-python python python-stdlib 3.11 builtins/set#(["ivo_managed"]), |
| 712 | service=dlSvc)) |
| 713 | |
| 714 | if addAllAllowed: # name=None was passed in, |
| 715 | # add publications for everything allowed but not yet marked |
| 716 | # as published (for VOSI) |
| 717 | alreadyPublished = setscip-python python python-stdlib 3.11 builtins/set#(p.render for p in result |
| 718 | # some TAP subrenderers never get capabilities for now |
| 719 | # (but then all this needs to change anyway; cf. caproles) |
| 720 | ) | frozensetscip-python python python-stdlib 3.11 builtins/frozenset#(["sync", "async", "user_tables"]) |
| 721 | |
| 722 | for rendName in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(self).allowed: |
| 723 | if not rendName in alreadyPublished: |
| 724 | result.appendscip-python python python-stdlib 3.11 builtins/list#append().(basescip-python python gavodachs 2.13 `gavo.base`/__init__:.makeStructscip-python python gavodachs 2.13 `gavo.base.structure`/makeStruct().(Publicationscip-python python gavodachs 2.13 `gavo.svcs.service`/Publication#, |
| 725 | render=rendName, sets=setscip-python python python-stdlib 3.11 builtins/set#(["vosi"]), service=selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(self))) |
| 726 | # these will only be added here for unpublished services |
| 727 | for pub in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getPublicationsForSet().(self)._iterAutomaticCapabilitiesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_iterAutomaticCapabilities().(): |
| 728 | if not pub.render in alreadyPublished: |
| 729 | result.appendscip-python python python-stdlib 3.11 builtins/list#append().(pub) |
| 730 | |
| 731 | return result |
| 732 | |
| 733 | # used by getBrowserURL; keep external higher than form as long as |
| 734 | # we have mess like Potsdam CdC. |
| 735 | _browserScoresscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_browserScores. = {"form": 10, "external": 12, "fixed": 15, |
| 736 | "custom": 8, "img.jpeg": 7, "static": 5, "hips": 3, "examples": 2} |
| 737 | |
| 738 | def getBrowserURLscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(self), fqscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(fq)=True): |
| 739 | """returns a published URL that's suitable for a web browser or None if |
| 740 | no such URL can be guessed. |
| 741 | |
| 742 | If you pass fq=False, you will get a path rather than a URL. |
| 743 | """ |
| 744 | # There can be multiple candidates for browser URLs (like when a service |
| 745 | # has both form, static, and external renderers). If so, we select |
| 746 | # by plain scores. |
| 747 | browseables = [] |
| 748 | for rendName in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(self).allowed: |
| 749 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(self).isBrowseableWithscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isBrowseableWith().(rendName): |
| 750 | browseables.appendscip-python python python-stdlib 3.11 builtins/list#append().((selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(self)._browserScoresscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_browserScores..getscip-python python python-stdlib 3.11 builtins/dict#get().(rendName, -1), rendName)) |
| 751 | if browseables: |
| 752 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(self).getURLscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(maxscip-python python python-stdlib 3.11 builtins/max().(browseables)[1], absolutescip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(absolute)=fqscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getBrowserURL().(fq)) |
| 753 | else: |
| 754 | return None |
| 755 | |
| 756 | def isBrowseableWithscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isBrowseableWith().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isBrowseableWith().(self), rendNamescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isBrowseableWith().(rendName)): |
| 757 | """returns true if rendering this service through rendName results |
| 758 | in something pretty in a web browser. |
| 759 | """ |
| 760 | try: |
| 761 | return boolscip-python python python-stdlib 3.11 builtins/bool#(renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(rendNamescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isBrowseableWith().(rendName)).isBrowseable(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#isBrowseableWith().(self))) |
| 762 | except basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NotFoundErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#: # renderer name not known |
| 763 | return False |
| 764 | |
| 765 | def getTableSetscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTableSet().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTableSet().(self)): |
| 766 | """returns a list of table definitions that have something to do with |
| 767 | this service. |
| 768 | |
| 769 | This is for VOSI-type requests. |
| 770 | |
| 771 | Basically, we're leaving the decision to the core, except when |
| 772 | we have an output Table of our own. |
| 773 | """ |
| 774 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTableSet().(self).outputTable and selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTableSet().(self).outputTable.columns: |
| 775 | return [selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTableSet().(self).outputTable] |
| 776 | |
| 777 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getTableSet().(self).core.getRelevantTables() |
| 778 | |
| 779 | def declareServesscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(self), datascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(data)): |
| 780 | """adds meta to self and data indicating that data is served by |
| 781 | this service. |
| 782 | |
| 783 | This is used by table/@adql and the publish element on data. |
| 784 | """ |
| 785 | if datascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(data).registration: |
| 786 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(self).addMetascip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#addMeta().("isServiceFor", |
| 787 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getMetaTextscip-python python gavodachs 2.13 `gavo.base.meta`/getMetaText().(datascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(data), "title", defaultscip-python python gavodachs 2.13 `gavo.base.meta`/getMetaText().(default)="Anonymous"), |
| 788 | ivoId=basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getMetaTextscip-python python gavodachs 2.13 `gavo.base.meta`/getMetaText().(datascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(data), "identifier")) |
| 789 | datascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(data).addMeta("isServedBy", |
| 790 | basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getMetaTextscip-python python gavodachs 2.13 `gavo.base.meta`/getMetaText().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(self), "title"), |
| 791 | ivoId=basescip-python python gavodachs 2.13 `gavo.base`/__init__:.getMetaTextscip-python python gavodachs 2.13 `gavo.base.meta`/getMetaText().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(self), "identifier")) |
| 792 | |
| 793 | # Since this is always initiated by the data, the dependency |
| 794 | # must show up in its RD to be properly added on publication |
| 795 | # and to be removed when the data is removed. |
| 796 | datascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(data).rd.addDependency(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(self).rd, datascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#declareServes().(data).rd) |
| 797 | |
| 798 | ########################## Output field selection |
| 799 | |
| 800 | _allSetscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_allSet. = setscip-python python python-stdlib 3.11 builtins/set#(["ALL"]) |
| 801 | |
| 802 | def _getFilteredColumnsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(self), columnSourcescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(columnSource), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(queryMeta), verbLevelscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(verbLevel)): |
| 803 | """filters columns in columnSource according to verbosity and column |
| 804 | set given in queryMeta. |
| 805 | |
| 806 | Actually, we only evaluate verbosity and requireSet. |
| 807 | """ |
| 808 | if queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(queryMeta)["columnSet"]: |
| 809 | columnSourcescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(columnSource) = [f for f in columnSourcescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(columnSource) |
| 810 | if f.sets==selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(self)._allSetscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_allSet. or queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(queryMeta)["columnSet"]&f.sets] |
| 811 | |
| 812 | return [f for f in columnSourcescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(columnSource) |
| 813 | if f.verbLevel<=verbLevelscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(verbLevel) and not f.hidden] |
| 814 | |
| 815 | def _getVOTableOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(self), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(queryMeta)): |
| 816 | """returns a list of OutputFields suitable for a VOTable |
| 817 | response described by queryMeta. |
| 818 | |
| 819 | This is the set of all columns in the source table below |
| 820 | the verbosity defined in queryMeta, except that columns |
| 821 | with a displayHint of noxml present are thrown out, too. |
| 822 | |
| 823 | When the service sets the votableRespectsOutputTable property to |
| 824 | "True", the column source is the service's output table rather |
| 825 | than the core's one. |
| 826 | """ |
| 827 | verbLevel = queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(queryMeta).get("verbosity") |
| 828 | if verbLevel=="HTML": |
| 829 | # SAMP transfers, typically: Pretend we're HTML |
| 830 | columnSource = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(self).getHTMLOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(queryMeta)) |
| 831 | verbLevel = 100 # column selection done by HTML, just filter noxml below |
| 832 | |
| 833 | elif (selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(self).getProperty("votableRespectsOutputTable", "").lower()=="true" |
| 834 | or queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(queryMeta)["columnSet"]): |
| 835 | columnSource = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(self).outputTable |
| 836 | |
| 837 | else: |
| 838 | columnSource = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(self).getAllOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getAllOutputFields().() |
| 839 | |
| 840 | fields = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(self)._getFilteredColumnsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().( |
| 841 | [f for f in columnSource |
| 842 | if f.displayHint.get("noxml")!="true"], |
| 843 | queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(queryMeta), |
| 844 | verbLevel) |
| 845 | |
| 846 | return rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.ColumnListscip-python python gavodachs 2.13 `gavo.rscdef.common`/ColumnList#(fields) |
| 847 | |
| 848 | def getHTMLOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(self), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMeta), ignoreAdditionalsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(ignoreAdditionals)=False, |
| 849 | raiseOnUnknownscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(raiseOnUnknown)=True): |
| 850 | """returns a list of OutputFields suitable for an HTML response described |
| 851 | by queryMeta. |
| 852 | |
| 853 | This is the service's output table if given, else the core's output |
| 854 | table at verbLevel 2. Additional fields can be set by the user. |
| 855 | |
| 856 | raiseOnUnknown is used by customwidgets to avoid exceptions because of |
| 857 | bad additional fields during form construction (when they aren't |
| 858 | properly caught). |
| 859 | """ |
| 860 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(self).outputTable: |
| 861 | columnSource, verbLevel = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(self).outputTable.columns, 20 |
| 862 | else: |
| 863 | columnSource, verbLevel = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(self).core.outputTable.columns, 20 |
| 864 | |
| 865 | if queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMeta)["verbosity"]!='HTML': |
| 866 | verbLevel = queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMeta)["verbosity"] |
| 867 | |
| 868 | fields = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(self)._getFilteredColumnsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getFilteredColumns().(columnSource, queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMeta), verbLevel) |
| 869 | |
| 870 | # add user-selected fields |
| 871 | if not ignoreAdditionalsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(ignoreAdditionals) and queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMeta)["additionalFields"]: |
| 872 | try: |
| 873 | for fieldName in queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMeta)["additionalFields"]: |
| 874 | col = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(self).core.outputTable.getColumnByName(fieldName) |
| 875 | if isinstance(col, outputdefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/__init__:.OutputFieldscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#): |
| 876 | fields.appendscip-python python python-stdlib 3.11 builtins/list#append().(col) |
| 877 | else: |
| 878 | fields.appendscip-python python python-stdlib 3.11 builtins/list#append().(outputdefscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/__init__:.OutputFieldscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#.fromColumnscip-python python gavodachs 2.13 `gavo.svcs.outputdef`/OutputField#fromColumn().(col)) |
| 879 | except basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NotFoundErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure# as msg: |
| 880 | if raiseOnUnknownscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(raiseOnUnknown): |
| 881 | raise basescip-python python gavodachs 2.13 `gavo.base`/__init__:.ValidationErrorscip-python python gavodachs 2.13 `gavo.base.structure`/Structure#("The additional field %s you requested" |
| 882 | " does not exist"%repr(msg.lookedForscip-python python gavodachs 2.13 `gavo.utils.excs`/NotFoundError#lookedFor.), colNamescip-python python gavodachs 2.13 `gavo.utils.excs`/ValidationError#__init__().(colName)="_OUTPUT") |
| 883 | |
| 884 | return rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.ColumnListscip-python python gavodachs 2.13 `gavo.rscdef.common`/ColumnList#(fields) |
| 885 | |
| 886 | def getCurOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(self), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMeta)=None, raiseOnUnknownscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(raiseOnUnknown)=True): |
| 887 | """returns a list of desired output fields for query meta. |
| 888 | |
| 889 | This is for both the core and the formatter to figure out the |
| 890 | structure of the tables passed. |
| 891 | """ |
| 892 | queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMeta) = queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMeta) or commonscip-python python gavodachs 2.13 `gavo.svcs.common`/__init__:.emptyQueryMetascip-python python gavodachs 2.13 `gavo.svcs.common`/emptyQueryMeta. |
| 893 | |
| 894 | # "renderer" in queryMeta needs to be set in the run method below; |
| 895 | # the net effect is that format will come from RESPONSEFORMAT, _FORMAT, |
| 896 | # and the renderer default in sequence. If none of that is available, |
| 897 | # blindly go for default HTML (which in retrospect perhaps wasn't the |
| 898 | # best choice for DaCHS, but changing this now to VOTable would introduce |
| 899 | # needless breakage). |
| 900 | renderer = queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMeta).getscip-python python python-stdlib 3.11 builtins/dict#get().("renderer") |
| 901 | format = queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMeta).getscip-python python python-stdlib 3.11 builtins/dict#get().("format", |
| 902 | getattrscip-python python python-stdlib 3.11 builtins/getattr().(renderer, "defaultOutputFormat", None)) or "HTML" |
| 903 | |
| 904 | if format in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(self).htmlLikeFormatsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#htmlLikeFormats.: |
| 905 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(self).getHTMLOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMeta), raiseOnUnknownscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getHTMLOutputFields().(raiseOnUnknown)=raiseOnUnknownscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(raiseOnUnknown)) |
| 906 | else: |
| 907 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(self)._getVOTableOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_getVOTableOutputFields().(queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMeta)) |
| 908 | |
| 909 | def getAllOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getAllOutputFields().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getAllOutputFields().(self)): |
| 910 | """Returns a sequence of all available output fields. |
| 911 | |
| 912 | This is what the core gives, and this is what will be declared |
| 913 | to the registry. Depending on the output format, the verbosity |
| 914 | level and perhaps other user settings, the actual columns produced |
| 915 | will be different. |
| 916 | """ |
| 917 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getAllOutputFields().(self).core.outputTable.columns |
| 918 | |
| 919 | ################### running and input computation. |
| 920 | |
| 921 | def getCoreForscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(self), rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(queryMeta)): |
| 922 | """returns a core tailored for renderer. |
| 923 | |
| 924 | See svcs.core's module docstring. |
| 925 | |
| 926 | The argument can be a renderer or a renderer name. |
| 927 | """ |
| 928 | if isinstance(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer), strscip-python python python-stdlib 3.11 builtins/str#): |
| 929 | rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer) = renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer)) |
| 930 | |
| 931 | # non-checked renderers use the core for info purposes only; don't |
| 932 | # bother for those |
| 933 | if not rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer).checkedRenderer: |
| 934 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(self).core |
| 935 | |
| 936 | if rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer).name not in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(self)._coresCachescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_coresCache.: |
| 937 | # Bad Hack: Tell datalink core what renderers are allowed on |
| 938 | # this service |
| 939 | allowedRendsForStealing = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(self).allowed #noflake: for stealVar downstack |
| 940 | |
| 941 | res = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(self).core.adaptForRenderer(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(queryMeta)) |
| 942 | |
| 943 | # Hack: let the polymorphous datalink core suppress caching |
| 944 | if getattrscip-python python python-stdlib 3.11 builtins/getattr().(res, "nocache", False): |
| 945 | return res |
| 946 | |
| 947 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(self)._coresCachescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_coresCache.[rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer).name] = res |
| 948 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(self)._coresCachescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_coresCache.[rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(renderer).name] |
| 949 | |
| 950 | def getContextGrammarForscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(self), rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(queryMeta), corescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(core)=None): |
| 951 | """returns an ContextGrammar appropriate for this renderer. |
| 952 | |
| 953 | Pass in the core if you already have it as an optimisation (in |
| 954 | particular for datalink, where cores aren't automatically cached); |
| 955 | if you don't the core will be computed from the renderer. |
| 956 | |
| 957 | In either case, the context grammar simply is built from the core's |
| 958 | inputTable. |
| 959 | """ |
| 960 | if isinstance(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(renderer), strscip-python python python-stdlib 3.11 builtins/str#): |
| 961 | rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(renderer) = renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(renderer)) |
| 962 | if corescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(core) is None: |
| 963 | corescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(core) = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(self).getCoreForscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(queryMeta)) |
| 964 | |
| 965 | serviceKeys = listscip-python python python-stdlib 3.11 builtins/list#(inputdefscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/__init__:.filterInputKeysscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/filterInputKeys().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(self).serviceKeys, |
| 966 | rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(renderer).name, inputdefscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/__init__:.getRendererAdaptorscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/getRendererAdaptor().(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(renderer)))) |
| 967 | |
| 968 | return MSscip-python python gavodachs 2.13 `gavo.svcs.service`/MS.(inputdefscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/__init__:.ContextGrammarscip-python python gavodachs 2.13 `gavo.base.structure`/ContextGrammar#, |
| 969 | inputTD=corescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().(core).inputTable, |
| 970 | inputKeys=serviceKeys) |
| 971 | |
| 972 | def getInputKeysForscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(self), rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(queryMeta)=commonscip-python python gavodachs 2.13 `gavo.svcs.common`/__init__:.emptyQueryMetascip-python python gavodachs 2.13 `gavo.svcs.common`/emptyQueryMeta.): |
| 973 | """returns a sequence of input keys, adapted for renderer. |
| 974 | |
| 975 | The renderer argument may either be a renderer name, a renderer |
| 976 | class or a renderer instance. |
| 977 | |
| 978 | This is the main interface for external entities to discover. |
| 979 | service metadata. |
| 980 | """ |
| 981 | if isinstance(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(renderer), strscip-python python python-stdlib 3.11 builtins/str#): |
| 982 | rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(renderer) = renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(renderer)) |
| 983 | return listscip-python python python-stdlib 3.11 builtins/list#(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(self).getContextGrammarForscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().( |
| 984 | rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getInputKeysFor().(queryMeta)).iterInputKeys()) |
| 985 | |
| 986 | def adaptCoreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(self), coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(queryMeta)): |
| 987 | """adapts a core result to the service's output table if appropriate. |
| 988 | |
| 989 | Frankly, this was an early mis-design that complicates matters |
| 990 | unnecessarily, but I can't really drop it as long as some interesting |
| 991 | things are based on service's outputTables. |
| 992 | |
| 993 | The adaptation works like this: |
| 994 | |
| 995 | (0) if coreRes isn't a table, or that table has a noPostprocess |
| 996 | attribute, return coreRes and let the renderer worry about it. |
| 997 | |
| 998 | (1) if names and units of newColumns the same as coreRes.columns, |
| 999 | accept coreRes as the new table |
| 1000 | |
| 1001 | (2) if names of newColumns are a subset of coreRes.columns match |
| 1002 | but one or more units don't, set up a conversion routine and create |
| 1003 | new rows, combining them with newColumns to the result. |
| 1004 | |
| 1005 | (3) else raise an error |
| 1006 | |
| 1007 | (4) eventually, wrap everything up in a rsc.Data instance for |
| 1008 | compatibility with cores actually returning data items. |
| 1009 | """ |
| 1010 | if not isinstance(coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes), rscscip-python python gavodachs 2.13 `gavo.rsc`/__init__:.BaseTablescip-python python gavodachs 2.13 `gavo.rsc.table`/BaseTable#): |
| 1011 | return coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes) |
| 1012 | |
| 1013 | newTable = coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes) |
| 1014 | if "requestURI" in queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(queryMeta): |
| 1015 | newTable.setMetascip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#setMeta().("request_uri", queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(queryMeta)["requestURI"]) |
| 1016 | |
| 1017 | if hasattr(coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes), "noPostprocess"): |
| 1018 | colDiffs, swallowColumns = None, None |
| 1019 | else: |
| 1020 | newColumns = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(self).getCurOutputFieldsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCurOutputFields().(queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(queryMeta)) |
| 1021 | swallowColumns = {c.name for c in coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes).tableDefscip-python python gavodachs 2.13 `gavo.rsc.table`/BaseTable#tableDef. |
| 1022 | }-{c.name for c in newColumns} |
| 1023 | colDiffs = basescip-python python gavodachs 2.13 `gavo.base`/__init__:.computeColumnConversionsscip-python python gavodachs 2.13 `gavo.base.unitconv`/computeColumnConversions().( |
| 1024 | newColumns, coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes).tableDefscip-python python gavodachs 2.13 `gavo.rsc.table`/BaseTable#tableDef..columns) |
| 1025 | |
| 1026 | if colDiffs or swallowColumns: |
| 1027 | newTd = coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes).tableDefscip-python python gavodachs 2.13 `gavo.rsc.table`/BaseTable#tableDef..change(columns=newColumns) |
| 1028 | newTd.copyMetaFrom(coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes).tableDefscip-python python gavodachs 2.13 `gavo.rsc.table`/BaseTable#tableDef.) |
| 1029 | |
| 1030 | if colDiffs: |
| 1031 | rmk = rscdefscip-python python gavodachs 2.13 `gavo.rscdef`/__init__:.RowmakerDefscip-python python gavodachs 2.13 `gavo.rscdef.rmkdef`/RowmakerDef#(None) |
| 1032 | for col in newColumns: |
| 1033 | exprStart = "" |
| 1034 | if col.name in colDiffs: |
| 1035 | exprStart = "%s*"%colDiffs[col.name] |
| 1036 | rmk.feedObject("map", rmkdefscip-python python gavodachs 2.13 `gavo.rscdef.rmkdef`/__init__:.MapRulescip-python python gavodachs 2.13 `gavo.rscdef.rmkdef`/MapRule#(rmk, dest=col.name, |
| 1037 | content_="%svars[%s]"%(exprStart, repr(col.name)) |
| 1038 | ).finishElement(None)) |
| 1039 | newTable = tablescip-python python gavodachs 2.13 `gavo.rsc.table`/__init__:.InMemoryTablescip-python python gavodachs 2.13 `gavo.rsc.table`/InMemoryTable#(newTd, validate=False) |
| 1040 | mapper = rmk.finishElement(None).compileForTableDef(newTd) |
| 1041 | for r in coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes): |
| 1042 | newTable.addRowscip-python python gavodachs 2.13 `gavo.rsc.table`/InMemoryTable#addRow().(mapper(r, newTable)) |
| 1043 | |
| 1044 | else: |
| 1045 | newTable = rscscip-python python gavodachs 2.13 `gavo.rsc`/__init__:.TableForDefscip-python python gavodachs 2.13 `gavo.rsc.tables`/TableForDef().(newTd, rows=coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes).rows) |
| 1046 | |
| 1047 | newTable._paramsscip-python python gavodachs 2.13 `gavo.rsc.common`/ParamMixin#_params. = coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes)._paramsscip-python python gavodachs 2.13 `gavo.rsc.common`/ParamMixin#_params. |
| 1048 | |
| 1049 | resData = rscscip-python python gavodachs 2.13 `gavo.rsc`/__init__:.wrapTablescip-python python gavodachs 2.13 `gavo.rsc.data`/wrapTable().(newTable, rdSourcescip-python python gavodachs 2.13 `gavo.rsc.data`/wrapTable().(rdSource)=coreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes).tableDefscip-python python gavodachs 2.13 `gavo.rsc.table`/BaseTable#tableDef.) |
| 1050 | |
| 1051 | return resData |
| 1052 | |
| 1053 | def _runWithInputTablescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(self), corescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(core), inputTablescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(inputTable), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(queryMeta)): |
| 1054 | """runs the core and returns a service result. |
| 1055 | """ |
| 1056 | queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(queryMeta)["inputTable"] = inputTablescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(inputTable) |
| 1057 | coreRes = corescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(core).run(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(self), inputTablescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(inputTable), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(queryMeta)) |
| 1058 | res = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(self).adaptCoreResscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#adaptCoreRes().(coreRes, queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(queryMeta)) |
| 1059 | |
| 1060 | return res |
| 1061 | |
| 1062 | def runscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(self), rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(renderer), argsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(args), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(queryMeta)): |
| 1063 | """runs the service, returning a service result. |
| 1064 | |
| 1065 | This is the main entry point for protocol renderers; args is |
| 1066 | a dict of lists as provided by request.strargs. |
| 1067 | """ |
| 1068 | if isinstance(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(renderer), strscip-python python python-stdlib 3.11 builtins/str#): |
| 1069 | rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(renderer) = renderersscip-python python gavodachs 2.13 `gavo.svcs.renderers`/__init__:.getRendererscip-python python gavodachs 2.13 functools/getRenderer#(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(renderer)) |
| 1070 | |
| 1071 | core = selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(self).getCoreForscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getCoreFor().(rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(queryMeta)) |
| 1072 | coreArgs = inputdefscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/__init__:.CoreArgsscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/CoreArgs#.fromRawArgsscip-python python gavodachs 2.13 `gavo.svcs.inputdef`/CoreArgs#fromRawArgs().( |
| 1073 | core.inputTable, argsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(args), selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(self).getContextGrammarForscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#getContextGrammarFor().( |
| 1074 | rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(renderer), queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(queryMeta), core)) |
| 1075 | queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(queryMeta)["renderer"] = rendererscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(renderer) |
| 1076 | |
| 1077 | return selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(self)._runWithInputTablescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_runWithInputTable().(core, coreArgs, queryMetascip-python python gavodachs 2.13 `gavo.svcs.service`/Service#run().(queryMeta)) |
| 1078 | |
| 1079 | |
| 1080 | #################### meta and such |
| 1081 | |
| 1082 | def _meta_availablescip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_available().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_available().(self)): |
| 1083 | # XXX TODO: have this ask the core |
| 1084 | return "true" |
| 1085 | |
| 1086 | def _meta_setsscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_sets().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_sets().(self)): |
| 1087 | # this is the union of the sets of the publications; this |
| 1088 | # is a bit lame, but it's a consequence of our mismatch |
| 1089 | # between publications, capabilities, and services. |
| 1090 | # In practice, these sets are meaningless where they are |
| 1091 | # pulled from meta (everywhere except in service selection |
| 1092 | # and in list identifiers, both of which don't use this). |
| 1093 | # There's a copy of this in registry.nonservice. |
| 1094 | sets = setscip-python python python-stdlib 3.11 builtins/set#() |
| 1095 | for p in selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_sets().(self).publications: |
| 1096 | sets |= p.sets |
| 1097 | if sets: |
| 1098 | return metascip-python python gavodachs 2.13 `gavo.base.meta`/__init__:.MetaItemscip-python python gavodachs 2.13 `gavo.base.meta`/MetaItem#.fromSequencescip-python python gavodachs 2.13 `gavo.base.meta`/MetaItem#fromSequence().( |
| 1099 | [metascip-python python gavodachs 2.13 `gavo.base.meta`/__init__:.MetaValuescip-python python gavodachs 2.13 `gavo.base.meta`/MetaValue#(s) for s in sets]) |
| 1100 | else: |
| 1101 | return None |
| 1102 | |
| 1103 | def macro_tablesForTAPscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#macro_tablesForTAP().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#macro_tablesForTAP().(self)): |
| 1104 | """returns a list of table names available for TAP querying. |
| 1105 | |
| 1106 | This, really, is an implementation detail for the TAP service and |
| 1107 | might go away anytime. |
| 1108 | """ |
| 1109 | # this is only used by tap.rd -- maybe it |
| 1110 | # should go there? |
| 1111 | from gavo.protocolsscip-python python gavodachs 2.13 `gavo.protocols`/__init__: import tapscip-python python gavodachs 2.13 `gavo.protocols.tap`/__init__: |
| 1112 | |
| 1113 | schemas = {} |
| 1114 | for qname in tapscip-python python gavodachs 2.13 `gavo.protocols.tap`/__init__:.getAccessibleTablesscip-python python gavodachs 2.13 `gavo.protocols.tap`/getAccessibleTables().(): |
| 1115 | try: |
| 1116 | schema, name = qname.split(".") |
| 1117 | except: # weird name |
| 1118 | continue |
| 1119 | schemas.setdefaultscip-python python python-stdlib 3.11 typing/MutableMapping#setdefault().(schema, []).append(name) |
| 1120 | |
| 1121 | return ", ".joinscip-python python python-stdlib 3.11 builtins/str#join().("%s from the %s schema"%(", ".joinscip-python python python-stdlib 3.11 builtins/str#join().(tables), schema) |
| 1122 | for schema, tables in schemas.itemsscip-python python python-stdlib 3.11 builtins/dict#items().()) |
| 1123 | |
| 1124 | def _meta_examplesLinkscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_examplesLink().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_examplesLink().(self)): |
| 1125 | """returns a link to a examples for this service if any |
| 1126 | are available. |
| 1127 | """ |
| 1128 | try: |
| 1129 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_examplesLink().(self).getMetascip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#getMeta().("_example", raiseOnFailscip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#getMeta().(raiseOnFail)=True) |
| 1130 | return basescip-python python gavodachs 2.13 `gavo.base`/__init__:.META_CLASSES_FOR_KEYSscip-python python gavodachs 2.13 builtins/META_CLASSES_FOR_KEYS#["_related"]( |
| 1131 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_examplesLink().(self).getURLscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().("examples", False), |
| 1132 | title="DALI examples") |
| 1133 | except basescip-python python gavodachs 2.13 `gavo.base`/__init__:.NoMetaKeyscip-python python gavodachs 2.13 `gavo.base.meta`/NoMetaKey#: |
| 1134 | return None |
| 1135 | |
| 1136 | def _meta_howtociteLinkscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_howtociteLink().(selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_howtociteLink().(self)): |
| 1137 | """returns a link to a how-to-cite page for this service as an URL |
| 1138 | meta. |
| 1139 | """ |
| 1140 | if selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_howtociteLink().(self).getMetascip-python python gavodachs 2.13 `gavo.base.meta`/MetaMixin#getMeta().("creationDate"): |
| 1141 | # depend on creationDate because to filter out totally whacko |
| 1142 | # RDs that will never make it to the Registry. |
| 1143 | return basescip-python python gavodachs 2.13 `gavo.base`/__init__:.META_CLASSES_FOR_KEYSscip-python python gavodachs 2.13 builtins/META_CLASSES_FOR_KEYS#["_related"]( |
| 1144 | selfscip-python python gavodachs 2.13 `gavo.svcs.service`/Service#_meta_howtociteLink().(self).getURLscip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().("howtocite", absolutescip-python python gavodachs 2.13 `gavo.svcs.service`/GetURLMixin#getURL().(absolute)=True), |
| 1145 | title="Advice on citing this resource") |