コード例 #1
0
    def completeElement(self, ctx):
        self._completeElementNext(Service, ctx)
        if not self.allowed:
            self.allowed.add("form")

        if self.core is base.Undefined:
            # undefined cores are only allowed with custom pages
            # (Deprecated)
            if self.customPage:
                self.core = core.getCore("nullCore")(
                    self.rd).finishElement(None)
                base.ui.notifyWarning(
                    "Custom page service %s without nullCore."
                    "  This is deprecated, please fix" % self.id)
            else:
                raise base.StructureError(
                    "Services must have cores (add <nullCore/>"
                    " if you really do not want a core, e.g., with fixed renderers)."
                )

        # if there's only one renderer on this service, make it the default
        if self.defaultRenderer is None and len(self.allowed) == 1:
            self.defaultRenderer = list(self.allowed)[0]
        # empty output tables are filled from the core
        if self.outputTable is base.NotGiven:
            self.outputTable = self.core.outputTable

        # cache all kinds of things expensive to create and parse
        self._coresCache = {}
        self._inputDDCache = {}
        self._loadedTemplates = {}

        # Schedule the capabilities to be added when the parse is
        # done (i.e., the RD is complete)
        ctx.addExitFunc(lambda rd, ctx: self._addAutomaticCapabilities())
コード例 #2
0
def getCoreDocs(docStructure):
    from gavo.svcs import core
    registry = dict((n, core.getCore(n)) for n in core.CORE_REGISTRY)
    return getStructDocsFromRegistry(registry, docStructure)
コード例 #3
0
    def _addAutomaticCapabilities(self):
        """adds some publications that are automatic for certain types
		of services.

		For services with ivo_managed publications and with useful cores
		(this keeps out doc-like publications, which shouldn't have VOSI
		resources), artificial VOSI publications are added.

		If there is _example meta, an examples publication is added.

		If this service exposes a table (i.e., a DbCore with a queriedTable)
		and that table is adql-readable, also add an auxiliary TAP publication
		if going to the VO.

		This is being run as an exit function from the parse context as
		we want the RD to be complete at this point (e.g., _examples
		meta might come from it).  This also lets us liberally resolve
		references anywhere.
		"""
        if not self.isVOPublished:
            return
        vosiSet = set(["ivo_managed"])

        # All actual services get VOSI caps
        if not isinstance(self.core, core.getCore("nullCore")):
            self._publications.feedObject(
                self,
                base.makeStruct(Publication,
                                render="availability",
                                sets=vosiSet,
                                parent_=self))
            self._publications.feedObject(
                self,
                base.makeStruct(Publication,
                                render="capabilities",
                                sets=vosiSet,
                                parent_=self))
            self._publications.feedObject(
                self,
                base.makeStruct(Publication,
                                render="tableMetadata",
                                sets=vosiSet,
                                parent_=self))

        # things querying tables get a TAP relationship if
        # their table is adql-queriable
        if isinstance(self.core, core.getCore("dbCore")):
            if self.core.queriedTable.adql:
                tapService = base.resolveCrossId("//tap#run")
                self._publications.feedObject(
                    self,
                    base.makeStruct(Publication,
                                    render="tap",
                                    sets=vosiSet,
                                    auxiliary=True,
                                    service=tapService,
                                    parent_=self))
                # and they need a servedBy, too.
                # According to the "discovering dependent" note, we don't
                # do the reverse relationship lest the TAP service
                # gets too related...
                self.addMeta("servedBy",
                             base.getMetaText(tapService, "title"),
                             ivoId=base.getMetaText(tapService, "identifier"))

        # things with examples meta get an examples capability
        try:
            self.getMeta("_example", raiseOnFail=True)
            self._publications.feedObject(
                self,
                base.makeStruct(Publication,
                                render="examples",
                                sets=utils.AllEncompassingSet(),
                                parent_=self))
        except base.NoMetaKey:
            pass
コード例 #4
0
 def _makeChild(self, name, parent):
     return core.getCore(name)(parent)