commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7647 - trunk/gnue-common/src/datasources


From: johannes
Subject: [gnue] r7647 - trunk/gnue-common/src/datasources
Date: Thu, 23 Jun 2005 08:18:17 -0500 (CDT)

Author: johannes
Date: 2005-06-23 08:18:16 -0500 (Thu, 23 Jun 2005)
New Revision: 7647

Modified:
   trunk/gnue-common/src/datasources/readgsd.py
Log:
Add multiple fk-references to the same table only once


Modified: trunk/gnue-common/src/datasources/readgsd.py
===================================================================
--- trunk/gnue-common/src/datasources/readgsd.py        2005-06-23 12:51:11 UTC 
(rev 7646)
+++ trunk/gnue-common/src/datasources/readgsd.py        2005-06-23 13:18:16 UTC 
(rev 7647)
@@ -60,6 +60,12 @@
     msg = u_("Tables have circular or unresolveable references")
     errors.ApplicationError.__init__ (self, msg)
 
+class CircualrDataReferences (errors.ApplicationError):
+  def __init__ (self, table):
+    msg = u_("Table '%s' contains circular/unresolvable record references") \
+          % table
+    errors.ApplicationError.__init__ (self, msg)
+
 class InvalidNumberError (errors.ApplicationError):
   def __init__ (self, value, length, scale):
     msg = u_("The value '%(value)s' is not a valid " \
@@ -362,7 +368,8 @@
         # Only add a dependency for a constraint, if we plan to add data for
         # that table too
         elif fkname in tables:
-          deps.append (fkname)
+          if not fkname in deps:
+            deps.append (fkname)
 
     needCommit = False
     for name in self.__orderByDependency (references):
@@ -425,7 +432,8 @@
           if rkey is not None:
             deps.append (rkey)
 
-      recOrder = self.__orderByDependency (sortdict)
+      recOrder = self.__orderByDependency (sortdict, CircularDataReferences,
+                                           table.name)
 
     else:
       recOrder = rows.keys ()
@@ -532,7 +540,7 @@
   # Order a given dependency tree
   # ---------------------------------------------------------------------------
 
-  def __orderByDependency (self, depTree):
+  def __orderByDependency (self, depTree, error = CircularReferenceError, *ea):
 
     result = []
 
@@ -555,7 +563,7 @@
       # If no key without a dependency was found, but there are still
       # entries in the tree, they *must* have circular references
       if not addition and depTree:
-        raise CircularReferenceError
+        raise error, ea
 
       result.extend (addition)
 





reply via email to

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