コード例 #1
0
    def getVOT(self, ctx):
        # the main trouble here is: What if there's multiple foreign keys
        # into destTD?  To prevent multiple inclusions of a single
        # table, we add a reference to our serialised VOTable stan in
        # destTD's _FKR_serializedVOT attribute.  That will fail
        # if we produce two VOTables from the same table at the same time,
        # but let's worry about that later.

        destTD = self.value.inTable
        srcTD = self.value.parent

        pkDecl = V.GROUP[V.VODML[V.ROLE["vo-dml:ObjectTypeInstance.ID"]], [
            V.FIELDref(
                ref=ctx.getOrMakeIdFor(destTD.tableDef.getColumnByName(colName)
                                       )) for colName in self.foreignKey.dest
        ]]
        pkDecl(ID=ctx.getOrMakeIdFor(pkDecl))

        fkDecl = V.GROUP(ref=ctx.getOrMakeIdFor(pkDecl))[
            V.VODML[V.TYPE["vo-dml:ORMReference"]], [
                V.FIELDref(ref=ctx.getIdFor(srcTD.getColumnByName(colName)))
                for colName in self.foreignKey.source
            ]]

        targetVOT = getattr(destTD, "_FKR_serializedVOT", lambda: None)()
        # weakrefs are None if expired
        if targetVOT is None:
            targetVOT = ctx.makeTable(destTD)
            destTD._FKR_serializedVOT = weakref.ref(targetVOT)
            ctx.getEnclosingResource()[targetVOT]

        targetVOT[pkDecl]

        return fkDecl
コード例 #2
0
def _iterNotes(serManager):
	"""yields GROUPs for table notes.

	The idea is that the note is in the group's description, and the FIELDrefs
	give the columns that the note applies to.
	"""
	# add notes as a group with FIELDrefs, but don't fail on them
	for key, note in serManager.notes.iteritems():
		noteId = serManager.getOrMakeIdFor(note)
		noteGroup = V.GROUP(name="note-%s"%key, ID=noteId)[
			V.DESCRIPTION[note.getContent(targetFormat="text")]]
		for col in serManager:
			if col["note"] is note:
				noteGroup[V.FIELDref(ref=col["id"])]
		yield noteGroup
コード例 #3
0
 def getVOT(self, ctx):
     return V.FIELDref(ref=ctx.getOrMakeIdFor(self.value))[V.VODML[V.ROLE[
         common.completeVODMLId(ctx, self.name)]]]