[Commits] (grant) Fix Bug 2875: Errors that occur while copying items are poorly reported

commits at osafoundation.org commits at osafoundation.org
Mon Apr 25 13:56:21 PDT 2005


Commit by: grant
Modified files:
chandler/application/Parcel.py 1.54 1.55

Log message:
Fix Bug 2875: Errors that occur while copying items are poorly reported

- Add the current file/line number to the tuple we record in
  Manager.addCopyOperation(). That way, if the copy later fails, we can
  report where the error actually occurred.

- If a .copy() returns None, raise a ParcelException with a more helpful
  error message.


Bugzilla links:
http://bugzilla.osafoundation.org/show_bug.cgi?id=2875

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/application/Parcel.py.diff?r1=text&tr1=1.54&r2=text&tr2=1.55

Index: chandler/application/Parcel.py
diff -u chandler/application/Parcel.py:1.54 chandler/application/Parcel.py:1.55
--- chandler/application/Parcel.py:1.54	Fri Mar 25 10:48:10 2005
+++ chandler/application/Parcel.py	Mon Apr 25 13:56:19 2005
@@ -597,7 +597,11 @@
 
             self.__parcelsWithData = None
             
-            for (reference, copyName, item, attributeName) in self.__copyOperations:
+            for (reference, copyName, item, attributeName, file, line) in self.__copyOperations:
+                # Make sure that any ParcelException we raise here reports
+                # the correct parcel.xml line / file
+                self.saveState(file, line)
+                
                 # We may be reloading, so if the copy is already there,
                 # remove it and re-copy
                 existingCopy = item.findPath(copyName)
@@ -607,7 +611,15 @@
                 # (either) Copy the item using cloud-copy:
                 copy = reference.copy(name=copyName, parent=item, 
                  cloudAlias="default")
-        
+                 
+                if copy == None:
+                    explanation = \
+                        ("Unable to make copy named '%s' for attribute '%s'. " + 
+                        "Maybe the original was moved/deleted?") % \
+                        (copyName, attributeName)
+                    self.saveExplanation(explanation)
+                    raise ParcelException(explanation)
+
                 # (or) Copy the item using attribute-copy:
                 # copy = reference.copy(name=copyName, parent=item)
         
@@ -654,8 +666,8 @@
             
         return result
 
-    def addCopyOperation(self, reference, copyName, item, attributeName):
-        self.__copyOperations.append((reference, copyName, item, attributeName))
+    def addCopyOperation(self, reference, copyName, item, attributeName, file, line):
+        self.__copyOperations.append((reference, copyName, item, attributeName, file, line))
         
     def resetState(self):
         self.currentXMLFile = None
@@ -1438,7 +1450,8 @@
                     # @@@ Special cases to resolve
                     if copyName:
                         self.manager.addCopyOperation(reference, copyName,
-                                                      item, attributeName)
+                                                      item, attributeName,
+                                                      file, line)
 
                     elif attributeName == 'inverseAttribute':
                         item.addValue('otherName', reference.itsName)



More information about the Commits mailing list