commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r8376 - trunk/gnue-common/src/definitions


From: johannes
Subject: [gnue] r8376 - trunk/gnue-common/src/definitions
Date: Wed, 5 Apr 2006 09:43:56 -0500 (CDT)

Author: johannes
Date: 2006-04-05 09:43:56 -0500 (Wed, 05 Apr 2006)
New Revision: 8376

Modified:
   trunk/gnue-common/src/definitions/GParser.py
   trunk/gnue-common/src/definitions/GParserHelpers.py
Log:
Check for valid attribute-values if a ValueSet is defined


Modified: trunk/gnue-common/src/definitions/GParser.py
===================================================================
--- trunk/gnue-common/src/definitions/GParser.py        2006-04-05 13:53:36 UTC 
(rev 8375)
+++ trunk/gnue-common/src/definitions/GParser.py        2006-04-05 14:43:56 UTC 
(rev 8376)
@@ -77,7 +77,18 @@
 
     self.detail = os.linesep.join (text)
 
+# =============================================================================
 
+class InvalidValueSetError (MarkupError):
+    def __init__ (self, attr, obj, vals):
+        msg = u_("'%(value)s' is not valid for %(attr)s-attribute which allows 
"
+                 "these values only: %(allowed)s") \
+              % {'attr': attr,
+                 'allowed': ",".join (["'%s'" % i for i in vals]),
+                 'value': getattr(obj, attr)}
+        MarkupError.__init__ (self, msg, obj._url, obj._lineNumber)
+
+
 # -----------------------------------------------------------------------------
 # Build an object from a XML stream
 # -----------------------------------------------------------------------------
@@ -526,6 +537,11 @@
     # Set the attributes
     object.__dict__.update (lattrs)
 
+    for (item, data) in baseAttrs.items ():
+        if 'ValueSet' in data:
+            if not getattr (object, item) in data ['ValueSet']:
+                raise InvalidValueSetError (item, object, data.keys ())
+
     self.xmlStack.insert (0, object)
     self.nameStack.insert (0, tname)
 

Modified: trunk/gnue-common/src/definitions/GParserHelpers.py
===================================================================
--- trunk/gnue-common/src/definitions/GParserHelpers.py 2006-04-05 13:53:36 UTC 
(rev 8375)
+++ trunk/gnue-common/src/definitions/GParserHelpers.py 2006-04-05 14:43:56 UTC 
(rev 8376)
@@ -347,7 +347,7 @@
     """
 
     for child in self._children:
-      if child.name == name:
+      if getattr (child, 'name', None) == name:
         if childType is None or child._type == childType:
           return child
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]