Changeset d69ce97 for fedd/federation


Ignore:
Timestamp:
Nov 12, 2010 8:44:51 AM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master
Children:
403a5ba
Parents:
9ecda47
Message:

Add version to topology object

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/topdl.py

    r9ecda47 rd69ce97  
    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.