check if the ticket was signed by a trusted cert
[sfa.git] / sfa / util / rspec.py
index 2b1fe85..fab1b57 100644 (file)
@@ -1,7 +1,6 @@
 ### $Id$
 ### $URL$
 
-import pdb
 import sys
 import pprint
 import os
@@ -9,7 +8,7 @@ import httplib
 from xml.dom import minidom
 from types import StringTypes, ListType
 
-class Rspec:
+class RSpec:
 
     def __init__(self, xml = None, xsd = None, NSURL = None):
         '''
@@ -92,6 +91,8 @@ class Rspec:
 
         if (nodeDom.hasChildNodes()):
             childdict={}
+            for attribute in nodeDom.attributes.keys():
+                childdict = self.appendToDictOrCreate(childdict, attribute, nodeDom.getAttribute(attribute))
             for child in nodeDom.childNodes[:-1]:
                 if (child.nodeValue):
                     siblingdict = self.appendToDictOrCreate(siblingdict, curNodeName, child.nodeValue)
@@ -101,17 +102,16 @@ class Rspec:
             child = nodeDom.childNodes[-1]
             if (child.nodeValue):
                 siblingdict = self.appendToDictOrCreate(siblingdict, curNodeName, child.nodeValue)
+                if (childdict):
+                    siblingdict = self.appendToDictOrCreate(siblingdict, curNodeName, childdict)
             else:
                 siblingdict = self.toGenDict(child, siblingdict, childdict, curNodeName)
-
-            # Keep the attributes separate from text nodes
-            attrdict={}
-            for attribute in nodeDom.attributes.keys():
-                attrdict = self.appendToDictOrCreate(attrdict, attribute, nodeDom.getAttribute(attribute))
-            if (attrdict):
-                self.appendToDictOrCreate(siblingdict, curNodeName, attrdict)
         else:
-            self.appendToDictOrCreate(siblingdict, curNodeName, [])
+            childdict={}
+            for attribute in nodeDom.attributes.keys():
+                childdict = self.appendToDictOrCreate(childdict, attribute, nodeDom.getAttribute(attribute))
+
+            self.appendToDictOrCreate(siblingdict, curNodeName, childdict)
             
         if (parentdict is not None):
             parentdict = self.appendToDictOrCreate(parentdict, parent, siblingdict)
@@ -274,7 +274,7 @@ class Rspec:
         """
         Convert a dictionary into a dom object and store it.
         """
-        self.rootNode = self.dict2dom(rdict, include_doc)
+        self.rootNode = self.dict2dom(rdict, include_doc).childNodes[0]
  
  
     def getDictsByTagName(self, tagname, dom = None):
@@ -363,7 +363,7 @@ class Rspec:
     
 
 
-class RecordSpec(Rspec):
+class RecordSpec(RSpec):
 
     root_tag = 'record'
     def parseDict(self, rdict, include_doc = False):
@@ -376,7 +376,7 @@ class RecordSpec(Rspec):
         record_dict = rdict
         if not len(rdict.keys()) == 1:
             record_dict = {self.root_tag : rdict}
-        return Rspec.dict2dom(self, record_dict, include_doc)
+        return RSpec.dict2dom(self, record_dict, include_doc)
 
         
 # vim:ts=4:expandtab