Changeset 1553d27


Ignore:
Timestamp:
Nov 12, 2010 8:46:13 AM (10 years ago)
Author:
Ted Faber <faber@…>
Branches:
version-3.02
Parents:
d608a90
Message:

Back port topology version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/topdl.py

    rd608a90 r1553d27  
    532532
    533533class Topology(base):
     534    version = "1.0"
    534535    @staticmethod
    535536    def init_element(e):
     
    554555            return e
    555556
    556     def __init__(self, substrates=[], elements=[], attribute=[]):
     557    def __init__(self, substrates=[], elements=[], attribute=[],
     558            version=None):
     559
     560        if version is None: self.version = Topology.version
     561        else: self.version = version
     562
    557563        self.substrates = [ self.init_class(Substrate, s) \
    558564                for s in self.make_list(substrates) ]
     
    619625        return Topology(substrates=[s.clone() for s in self.substrates],
    620626                elements=[e.clone() for e in self.elements],
    621                 attribute=[a.clone() for a in self.attribute])
     627                attribute=[a.clone() for a in self.attribute],
     628                version=self.version)
    622629
    623630
     
    628635    def to_dict(self):
    629636        rv = { }
     637        rv['version'] = self.version
    630638        if self.substrates:
    631639            rv['substrates'] = [ s.to_dict() for s in self.substrates ]
     
    637645
    638646    def to_xml(self):
    639         rv = ""
     647        rv = "<version>%s</version>" % escape(self.version)
    640648        if self.substrates:
    641649            rv += join(["<substrates>%s</substrates>" % s.to_xml() \
Note: See TracChangeset for help on using the changeset viewer.