def completeElement(self, ctx):
        # we want a meta parent as soon as possible, and we always let it
        # be our struct parent
        if (not self.getMetaParent() and self.parent
                and hasattr(self.parent, "_getMeta")):
            self.setMetaParent(self.parent)

        # Make room for DM annotations (these are currently filled by
        # gavo.dm.dmrd.DataModelRoles, but we might reconsider this)
        self.annotations = []

        if self.viewStatement and getattr(ctx, "restricted", False):
            raise base.RestrictedElement(
                "table",
                hint="tables with"
                " view creation statements are not allowed in restricted mode")

        if self.registration and self.id is base.NotGiven:
            raise base.StructureError("Published tables need an assigned id.")
        if not self.id:
            self._id.feed(ctx, self, utils.intToFunnyWord(id(self)))

        # allow iterables to be passed in for columns and convert them
        # to a ColumnList here
        if not isinstance(self.columns, common.ColumnList):
            self.columns = common.ColumnList(self.columns)
        self._resolveSTC()
        self._completeElementNext(TableDef, ctx)
        self.columns.withinId = self.params.tableName = "table " + self.id
Example #2
0
 def completeElement(self, ctx):
     if self.restrictedMode and (self.formatter or self.select):
         raise base.RestrictedElement(
             self.name_,
             hint="formatter and select"
             " attributes on output fields are not allowed in restricted mode."
         )
     if self.select is base.Undefined:
         self.select = self.name
     self._completeElementNext(OutputField, ctx)
 def completeElement(self, ctx):
     if self.content_ and getattr(ctx, "restricted", False):
         raise base.RestrictedElement("index",
                                      hint="Free-form SQL on indices"
                                      " is not allowed in restricted mode")
     self._completeElementNext(DBIndex, ctx)
     if not self.columns:
         raise base.StructureError("Index without columns is verboten.")
     if self.name is base.Undefined:
         self.name = "%s" % (re.sub("[^\w]+", "_", "_".join(self.columns)))
     if not self.content_:
         self.content_ = "%s" % ",".join(self.columns)
	def completeElement(self, ctx):
		self.restrictedMode = getattr(ctx, "restricted", False)
		if self.restrictedMode and (
				self.content_
				or self.nullExpr
				or self.nullValue):
			raise base.RestrictedElement("map", hint="In restricted mode, only"
				" maps with a source attribute are allowed; nullExpr or nullValue"
				" are out, too, since they can be used to inject raw code.")
		if not self.content_ and not self.source:
			self.source = self.key
		if self.content_ and "\\" in self.content_:
			self.content_ = self.parent.expand(self.content_)
 def completeElement(self, ctx):
     self._completeElementNext(InputKey, ctx)
     if self.restrictedMode and self.widgetFactory:
         raise base.RestrictedElement("widgetFactory")
Example #6
0
 def validate(self):
     self._validateNext(ColumnBase)
     if self.restrictedMode and self.fixup:
         raise base.RestrictedElement("fixup")