mailr10410 - /branches/bieri_gui/data/data_classes.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 26, 2010 - 19:23:
Author: bugman
Date: Tue Jan 26 19:23:37 2010
New Revision: 10410

URL: http://svn.gna.org/viewcvs/relax?rev=10410&view=rev
Log:
Elements of the RelaxListType have their to_xml() method called, if it exists.


Modified:
    branches/bieri_gui/data/data_classes.py

Modified: branches/bieri_gui/data/data_classes.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/bieri_gui/data/data_classes.py?rev=10410&r1=10409&r2=10410&view=diff
==============================================================================
--- branches/bieri_gui/data/data_classes.py (original)
+++ branches/bieri_gui/data/data_classes.py Tue Jan 26 19:23:37 2010
@@ -186,7 +186,7 @@
         # Set the list attributes.
         list_element.setAttribute('desc', self.list_desc)
 
-        # Add all simple python objects within the PipeContainer to the pipe 
element.
+        # Add all simple python objects within the list to the list element.
         fill_object_contents(doc, list_element, object=self, 
blacklist=list(self.__class__.__dict__.keys() + list.__dict__.keys()))
 
         # Loop over the list.
@@ -197,5 +197,24 @@
             element.setAttribute('index', repr(i))
             element.setAttribute('desc', self.element_desc)
 
-            # Add all simple python objects within the PipeContainer to the 
pipe element.
-            fill_object_contents(doc, element, object=self[i], 
blacklist=list(self[i].__class__.__dict__.keys()))
+            # Blacklisted objects.
+            blacklist = list(self[i].__class__.__dict__.keys())
+
+            # Add objects which have to_xml() methods.
+            for name in dir(self[i]):
+                # Skip blacklisted objects.
+                if name in blacklist:
+                    continue
+
+                # Skip special objects.
+                if search('^_', name):
+                    continue
+
+                # Execute any to_xml() methods, and add that object to the 
blacklist.
+                obj = getattr(self[i], name)
+                if hasattr(obj, 'to_xml'):
+                    obj.to_xml(doc, element)
+                    blacklist = blacklist + [name]
+
+            # Add all simple python objects within the container to the XML 
element.
+            fill_object_contents(doc, element, object=self, 
blacklist=blacklist)




Related Messages


Powered by MHonArc, Updated Tue Jan 26 20:00:02 2010