[CMF-checkins] SVN: CMF/trunk/GenericSetup/utils.py Improved debugging support.

Florent Guillaume fg at nuxeo.com
Thu Dec 29 12:40:53 EST 2005


Log message for revision 41052:
  Improved debugging support.
  

Changed:
  U   CMF/trunk/GenericSetup/utils.py

-=-
Modified: CMF/trunk/GenericSetup/utils.py
===================================================================
--- CMF/trunk/GenericSetup/utils.py	2005-12-29 02:04:20 UTC (rev 41051)
+++ CMF/trunk/GenericSetup/utils.py	2005-12-29 17:40:52 UTC (rev 41052)
@@ -24,6 +24,7 @@
 from xml.dom.minidom import Node
 from xml.dom.minidom import parseString
 from xml.sax.handler import ContentHandler
+from xml.parsers.expat import ExpatError
 
 import Products
 from AccessControl import ClassSecurityInfo
@@ -512,7 +513,13 @@
     def _importBody(self, body):
         """Import the object from the file body.
         """
-        self._importNode(parseString(body).documentElement)
+        try:
+            dom = parseString(body)
+        except ExpatError, e:
+            filename = (self.filename or
+                        '/'.join(self.context.getPhysicalPath()))
+            raise ExpatError('%s: %s' % (filename, e))
+        self._importNode(dom.documentElement)
 
     mime_type = 'text/xml'
 
@@ -520,6 +527,7 @@
 
     suffix = '.xml'
 
+    filename = '' # for error reporting during import
 
 class ObjectManagerHelpers(object):
 
@@ -553,6 +561,7 @@
             obj_id = str(child.getAttribute('name'))
             if obj_id not in parent.objectIds():
                 meta_type = str(child.getAttribute('meta_type'))
+                __traceback_info__ = obj_id, meta_type
                 for mt_info in Products.meta_types:
                     if mt_info['name'] == meta_type:
                         parent._setObject(obj_id, mt_info['instance'](obj_id))
@@ -709,6 +718,7 @@
     """
     importer = zapi.queryMultiAdapter((obj, context), IBody)
     path = '%s%s' % (parent_path, obj.getId().replace(' ', '_'))
+    __traceback_info__ = path
     if importer:
         if importer.name:
             path = '%s%s' % (parent_path, importer.name)
@@ -718,6 +728,7 @@
             # BBB: for CMF 1.5 profiles
             body = context.readDataFile('typestool.xml')
         if body is not None:
+            importer.filename = filename # for error reporting
             importer.body = body
 
     if getattr(obj, 'objectValues', False):



More information about the CMF-checkins mailing list