[Zope3-checkins] CVS: Zope3/src/zope/configuration - xmlconfig.py:1.7

Jim Fulton jim@zope.com
Thu, 12 Jun 2003 05:28:13 -0400


Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv26013/src/zope/configuration

Modified Files:
	xmlconfig.py 
Log Message:
Changed the formatting of SAX parse errors so they are understood by
emacs compile mode.


=== Zope3/src/zope/configuration/xmlconfig.py 1.6 => 1.7 ===
--- Zope3/src/zope/configuration/xmlconfig.py:1.6	Tue Mar 11 15:11:18 2003
+++ Zope3/src/zope/configuration/xmlconfig.py	Thu Jun 12 05:28:11 2003
@@ -24,6 +24,7 @@
 from xml.sax import make_parser
 from xml.sax.xmlreader import InputSource
 from xml.sax.handler import ContentHandler, feature_namespaces
+from xml.sax import SAXParseException
 from zope.configuration import name
 from zope.configuration.meta import begin, sub, end
 from zope.configuration.exceptions import ConfigurationError
@@ -53,10 +54,22 @@
         self.mess = mess
 
     def __str__(self):
-        return 'File "%s", line %s, column %s\n\t%s' % (
+        return 'File "%s", line %s.%s\n\t%s' % (
             self.sid, self.lno, self.cno, self.mess)
 
 
+class ZopeSAXParseException(ConfigurationError):
+    def __init__(self, v):
+        self._v = v
+
+    def __str__(self):
+        v = self._v
+        s = tuple(str(v).split(':'))
+        if len(s) == 4:
+            return 'File "%s", line %s.%s, %s' % s
+        else:
+            return str(v)
+        
 class ConfigurationExecutionError(ZopeXMLConfigurationError):
     """An error occurred during execution of a configuration action
     """
@@ -240,7 +253,10 @@
                              testing=testing)
         )
     parser.setFeature(feature_namespaces, 1)
-    parser.parse(src)
+    try:
+        parser.parse(src)
+    except SAXParseException:
+        raise ZopeSAXParseException, sys.exc_info()[1], sys.exc_info()[2]
 
     if call:
         descriptors = {}