[gnue] r9923 - in trunk: gnue-common/src/apps gnue-common/src/base gnue-common/src/datasources gnue-common/src/datasources/drivers/DBSIG2 gnue-common/src/datasources/drivers/other gnue-common/src/datasources/drivers/sql/maxdb gnue-common/src/definitions gnue-common/src/logic/adapters gnue-common/src/rpc gnue-common/src/rpc/drivers/hessian gnue-common/src/rpc/drivers/xmlrpc gnue-common/src/utils gnue-forms/src

[email protected]
Newsgroups gmane.comp.cms.gnue.cvs
Message-ID <[email protected]>
Author: reinhard
Date: 2009-10-02 10:29:26 -0500 (Fri, 02 Oct 2009)
New Revision: 9923

Modified:
   trunk/gnue-common/src/apps/GBaseApp.py
   trunk/gnue-common/src/apps/errors.py
   trunk/gnue-common/src/base/errors.py
   trunk/gnue-common/src/base/log.py
   trunk/gnue-common/src/datasources/GConnections.py
   trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
   trunk/gnue-common/src/datasources/drivers/other/appserver.py
   trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py
   trunk/gnue-common/src/datasources/readgsd.py
   trunk/gnue-common/src/definitions/GParser.py
   trunk/gnue-common/src/logic/adapters/ecmascript.py
   trunk/gnue-common/src/logic/adapters/python.py
   trunk/gnue-common/src/rpc/client.py
   trunk/gnue-common/src/rpc/drivers/hessian/ClientAdapter.py
   trunk/gnue-common/src/rpc/drivers/hessian/ServerAdapter.py
   trunk/gnue-common/src/rpc/drivers/xmlrpc/ClientAdapter.py
   trunk/gnue-common/src/rpc/drivers/xmlrpc/ServerAdapter.py
   trunk/gnue-common/src/utils/plugin.py
   trunk/gnue-forms/src/GFInstance.py
Log:
Cleanup of exception handling code.


Modified: trunk/gnue-common/src/apps/GBaseApp.py
===================================================================
--- trunk/gnue-common/src/apps/GBaseApp.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/apps/GBaseApp.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -39,9 +39,9 @@
 
 from gnue import paths
 
-from gnue.common.base import log
+from gnue.common.base import errors, log
 from gnue.common.apps.i18n import utranslate as u_
-from gnue.common.apps import errors, GConfig, GDebug
+from gnue.common.apps import GConfig, GDebug
 from gnue.common.datasources import GConnections
 from gnue.common.apps.CommandOption import CommandOption
 
@@ -768,15 +768,14 @@
     # Catch an exception
     # -------------------------------------------------------------------------
 
-    def excepthook(self, etype, value, traceback):
+    def excepthook(self, etype, evalue, etraceback):
         """
-        This function catches an exception and evaluates it using
-        getException().  The exception-tuple is then passed to showException(),
-        which might get overriden by a descendant.
+        Handle an exception.
         """
+
         sys.excepthook = sys.__excepthook__
-        log.excepthook(etype, value, traceback)
-        self._showException(*errors.getException(None, etype, value, traceback))
+        log.excepthook(etype, evalue, etraceback)
+        self._showException(*errors.format_exception(etype, evalue, etraceback))
         sys.excepthook = self.excepthook
 
 

Modified: trunk/gnue-common/src/apps/errors.py
===================================================================
--- trunk/gnue-common/src/apps/errors.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/apps/errors.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -27,6 +27,8 @@
 This module is *DEPRECATED*. Please use gnue.common.base.errors instead
 """
 
+# TODO: Deprecate everything in here with 0.8, remove with 0.9
+
 import sys
 import traceback
 import types
@@ -49,91 +51,16 @@
     """
     This class is *DEPRECATED*. Please use gnue.common.base.errors.Error
     instead.
-
-    The same as the builtin python Exception, but can handle messages that are
-    unicode strings.  This exception is available as the builtin class
-    "gException".  All other user-defined exceptions should be derived from
-    this class.
-
-    @ivar message: The error message.
-    @type message: Unicode
-    @ivar group: The group or category of the exception. Can be one of 'system',
-      'admin', 'application', or 'user'.
-    @ivar name: The name of the exception. If set, this will be returned by
-      L{getName} and L{getException} instead of the class name of the exception.
-    @ivar detail: The detail information to the exception. If set, this will be
-      returned by L{getDetail} and L{getException} instead of the traceback.
     """
     def __init__(self, message, group='system'):
         errors.Error.__init__(self, message)
 
 
-    # -------------------------------------------------------------------------
-    # Get the type of the exception
-    # -------------------------------------------------------------------------
-
-    def getGroup(self):
-        """
-        Return the group of the exception.
-
-        @return: Group of the exception, one of 'system', 'admin',
-            'application', or 'user'.
-        """
-        return self.group
-
-
-    # -------------------------------------------------------------------------
-    # Return the name of the exception
-    # -------------------------------------------------------------------------
-
-    def getName(self, aType=None):
-        """
-        Return the exception's name, which is the classname of the exception
-        class unless overwritten with L{name}.
-
-        @return: Name of the exception.
-        @rtype: Unicode
-        """
-        return self.get_name(aType)
-
-
-    # -------------------------------------------------------------------------
-    # Get the detail of an exception
-    # -------------------------------------------------------------------------
-
-    def getDetail(self, count=None, type=None, value=None, trace=None):
-        """
-        Return the exception's detail, which is the traceback unless
-        overwritten with L{detail}.
-
-        Optionally, a number of lines can be skipped at the beginning of the
-        traceback (if the detail I{is} the traceback).
-
-        @param count: Number of lines to skip at the beginning of the traceback.
-        @return: Detail information for the exception.
-        @rtype: Unicode
-        """
-        return self.get_detail(count, type, value, trace)
-
-
-    # -------------------------------------------------------------------------
-    # Get the message of an exception
-    # -------------------------------------------------------------------------
-
-    def getMessage(self):
-        """
-        Return the message of an exception.
-        @return: Message of the exception.
-        @rtype: Unicode
-        """
-        return self.message
-
-
 # -----------------------------------------------------------------------------
 # Get a tuple (type, name, message, detail) for the last exception raised
 # -----------------------------------------------------------------------------
 
-def getException(count=None, aType=None, aValue=None, aTrace=None):
+def getException(count=None):
     """
     This function is *DEPRECATED*. Please use
     gnue.common.base.errors.get_exception instead.
@@ -150,4 +77,4 @@
     @param count: number of lines to skip in the traceback
     @return: tuple with group, name, message and detail of the last exception.
     """
-    return errors.get_exception(count, aType, aValue, aTrace)
+    return errors.get_exception(tb_skip=count)

Modified: trunk/gnue-common/src/base/errors.py
===================================================================
--- trunk/gnue-common/src/base/errors.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/base/errors.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -22,45 +22,46 @@
 # $Id$
 
 """
-General exception classes.
+Unicode enabled exception base classes.
 """
 
 import sys
 import traceback
 import types
-import exceptions
 
 from gnue.common.base import i18n
 
-__all__ = ['get_exception', 'SystemError', 'AdminError', 'ApplicationError',
-           'UserError', 'RemoteError']
+__all__ = ['SystemError', 'AdminError', 'ApplicationError', 'UserError',
+        'RemoteError', 'get_exception', 'format_exception']
 
 
 # =============================================================================
 # Base exception class for all GNUe Exceptions
 # =============================================================================
 
-class Error(exceptions.Exception):
+class Error(Exception):
     """
     The same as the builtin python Exception, but can handle messages that are
     unicode strings.  All other user-defined exceptions should be derived from
     this class.
 
     @ivar message: The error message.
-    @type message: Unicode
+    @type message: unicode
     @ivar group: The group or category of the exception. Can be one of 'system',
         'admin', 'application', or 'user'.
-    @ivar name: The name of the exception. If set, this will be returned by
-        L{get_name} and L{get_exception} instead of the class name of the
-        exception.
+    @type group: str
+    @ivar name: The name of the exception class. If set, this will be returned
+        by L{get_exception} and L{format_exception} instead of the class name
+        of the exception.
+    @type name: unicode or None
     @ivar detail: The detail information to the exception. If set, this will be
-        returned by L{get_detail} and L{get_exception} instead of the
+        returned by L{get_exception} and L{format_exception} instead of the
         traceback.
+    @type name: unicode or None
     """
-    def __init__(self, message, group='system'):
 
-        exceptions.Exception.__init__(self, o(message))
-
+    def __init__(self, message, group='system'):
+        Exception.__init__(self, i18n.outconv(message))
         self.message = message
         self.group   = group
         self.name    = None
@@ -68,65 +69,13 @@
 
 
     # -------------------------------------------------------------------------
-    # Return the name of the exception
+    # Unicode representation
     # -------------------------------------------------------------------------
 
-    def get_name(self, exc_type=None):
-        """
-        Return the exception's name, which is the classname of the exception
-        class unless overwritten with L{name}.
+    def __unicode__(self):
+        return self.message
 
-        @param exc_type: Type of the exception class to be used if no name is
-            defined and the exception being handled is no longer available in
-            sys.exc_info()
 
-        @return: Name of the exception.
-        @rtype: Unicode
-        """
-
-        if self.name is not None:
-            return self.name
-
-        t = sys.exc_info()[0] or exc_type
-        if issubclass(t, Exception):
-            return unicode(t.__name__)
-        else:
-            return unicode(t)
-
-
-    # -------------------------------------------------------------------------
-    # Get the detail of an exception
-    # -------------------------------------------------------------------------
-
-    def get_detail(self, count=None, etype=None, evalue=None, etrace=None):
-        """
-        Return the exception's detail, which is the traceback unless
-        overwritten with L{detail}.
-
-        Optionally, a number of lines can be skipped at the beginning of the
-        traceback (if the detail I{is} the traceback).
-
-        @param count: Number of lines to skip at the beginning of the traceback.
-        @return: Detail information for the exception.
-        @rtype: Unicode
-        """
-        if self.detail is not None:
-            return self.detail
-
-        (stype, svalue, strace) = sys.exc_info()
-        stype  = stype or etype
-        svalue = svalue or evalue
-        strace = strace or etrace
-
-        stack = traceback.format_exception(stype, svalue, strace)
-        if count is not None:
-            del stack[1:count + 1]
-
-        # sys.exc_info() and traceback.format_exception() return 8-bit strings
-        # in the current encoding, so we have to convert them back to Unicode.
-        return i18n.inconv(''.join(stack))
-
-
 # =============================================================================
 # System Error
 # =============================================================================
@@ -136,6 +85,7 @@
     This exception class should be used for exceptions indicating a bug in
     GNUe.  Whenever such an exception is raised, one have found such a bug :)
     """
+
     def __init__(self, message):
         Error.__init__(self, message, 'system')
 
@@ -150,6 +100,7 @@
     misconfiguration in a widest sense. This could be a missing module for a
     dbdriver as well as an 'out of disk space' error.
     """
+
     def __init__(self, message):
         Error.__init__(self, message, 'admin')
 
@@ -163,6 +114,7 @@
     This class should be used for errors caused by applications like a corrupt
     trigger code, or a misformed xml-file and so on.
     """
+
     def __init__(self, message):
         Error.__init__(self, message, 'application')
 
@@ -178,6 +130,7 @@
     informed of. Example: wrong password or the user has entered non-numeric
     data into a numeric field, and so on.
     """
+
     def __init__(self, message):
         Error.__init__(self, message, 'user')
 
@@ -192,6 +145,7 @@
     Once it has been created it never changes it's contents. A remote error
     usually contains System-, Admin- or User-Errors.
     """
+
     def __init__(self, group, name, message, detail):
         Error.__init__(self, message)
         self.group  = group
@@ -199,50 +153,66 @@
         self.detail = detail
 
 
+# =============================================================================
+# Exception info formatting routines
+# =============================================================================
+
 # -----------------------------------------------------------------------------
 # Get a tuple (type, name, message, detail) for the last exception raised
 # -----------------------------------------------------------------------------
 
-def get_exception(count=None, exc_type=None, exc_value=None, exc_tback=None):
+def get_exception(tb_skip=None):
     """
-    Return textual information about an exception.
+    Return a tuple (group, name, message, detail) for the last occured
+    exception.
 
-    This function creates a tuple (group, name, message, detail) for the last
-    exception raised. The optional parameter determines the number of lines
-    skipped from the detail traceback.
+    @param tb_skip: Number of traceback lines to suppress at the beginning.
+    """
 
-    The intended use of this function is to get the text to be displayed in
-    error messages.
+    (etype, evalue, etraceback) = sys.exc_info()
+    result = format_exception(etype, evalue, etraceback, tb_skip)
+    del etype, evalue, etraceback
+    return result
 
-    @param count: number of lines to skip in the traceback
-    @return: tuple with group, name, message and detail of the last exception.
+
+# -----------------------------------------------------------------------------
+# Format a given exception
+# -----------------------------------------------------------------------------
+
+def format_exception(etype, evalue, etraceback, tb_skip=None):
     """
-    (sType, sValue, sTrace) = sys.exc_info()
+    Return a tuple (group, name, message, detail) for the exception.
 
-    exc_type  = exc_type  or sType
-    exc_value = exc_value or sValue
-    exc_tback = exc_tback or sTrace
+    @param etype, evalue, etraceback: Exception info as returned by
+        sys.exc_info().
+    @param tb_skip: Number of traceback lines to suppress at the beginning.
+    """
 
-    if isinstance(exc_value, Error):
-        return (exc_value.group,
-                exc_value.get_name(exc_type),
-                exc_value.message,
-                exc_value.get_detail(count, exc_type, exc_value, exc_tback))
+    # group
+    if isinstance(evalue, Error):
+        group = evalue.group
     else:
-        # Exception was not a descendant of Error, so we construct the
-        # tuple from the exception information
-        lines = traceback.format_exception(exc_type, exc_value, exc_tback)
-        if count is not None:
-            del lines[1:count + 1]
+        group = 'system'
 
-        if isinstance(exc_type, types.InstanceType):
-            name = unicode(exc_type)
+    # name
+    if isinstance(evalue, Error) and evalue.name is not None:
+        name = evalue.name
+    else:
+        if isinstance(etype, types.InstanceType):
+            name = unicode(etype)
         else:
-            name = unicode(exc_type.__name__)
-        name = name.split('.')[-1]
-        message = unicode(exc_value)
-        detail  = ''.join(lines)
-        if isinstance(detail, str):
-            detail = i18n.inconv(detail)
+            name = unicode(etype.__name__)
 
-        return ('system', name, message, detail)
+    # detail
+    if isinstance(evalue, Error) and evalue.detail is not None:
+        detail = evalue.detail
+    else:
+        lines = traceback.format_exception(etype, evalue, etraceback)
+        # Delete lines in the traceback as requested.
+        if tb_skip:
+            del lines[1:tb_skip + 1]
+        # traceback.format_exception() returns an 8 bit string encoded in the
+        # current encoding, so we have to convert to Unicode.
+        detail = i18n.inconv(''.join(lines))
+
+    return (group, name, unicode(evalue), detail)

Modified: trunk/gnue-common/src/base/log.py
===================================================================
--- trunk/gnue-common/src/base/log.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/base/log.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -35,8 +35,7 @@
 import sys
 import traceback
 
-from gnue.common.base import utils
-from gnue.common.apps import errors
+from gnue.common.base import errors, utils
 
 __all__ = ['logged_f', 'deprecated_f',
         'logged_f_n', 'deprecated_f_n',
@@ -310,12 +309,13 @@
     @param etraceback: Exception traceback
     @type etraceback: traceback
     """
-    (group, name, message, detail) = errors.getException(None, etype, evalue,
+    (group, name, message, detail) = errors.format_exception(etype, evalue,
             etraceback)
-    logger = "exception.%s.%s" % (group, etype)
+    logger = "exception.%s.%s" % (group, name)
     text = u_("Unhandled exception %s:\n%s") % (name, detail)
     error_n(logger, text)
 
+
 # -----------------------------------------------------------------------------
 # Exception and call stack logging
 # -----------------------------------------------------------------------------

Modified: trunk/gnue-common/src/datasources/GConnections.py
===================================================================
--- trunk/gnue-common/src/datasources/GConnections.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/datasources/GConnections.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -488,9 +488,9 @@
             # We're done!
             attempts = 0
 
-          except Exceptions.LoginError:
+          except Exceptions.LoginError, e:
             attempts  -= 1
-            errortext  = errors.getException () [2]
+            errortext  = unicode(e)
 
             if not attempts:
               # Four times is plenty...

Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -128,8 +128,8 @@
     assert gDebug (3, 'DBSIG2 Connect')
     try:
       self._native = self._driver.connect (*params, **kwargs)
-    except self._driver.DatabaseError:
-      raise Exceptions.LoginError, errors.getException () [2]
+    except self._driver.DatabaseError, e:
+      raise Exceptions.LoginError(unicode(e))
 
   # ---------------------------------------------------------------------------
 
@@ -191,9 +191,8 @@
     assert gDebug (3, 'DBSIG2 Commit')
     try:
       self._native.commit ()
-    except self._driver.DatabaseError:
-      raise Exceptions.ConnectionError, (errors.getException () [2], 'COMMIT',
-          None)
+    except self._driver.DatabaseError, e:
+      raise Exceptions.ConnectionError(unicode(e), 'COMMIT', None)
 
   # ---------------------------------------------------------------------------
 
@@ -367,10 +366,9 @@
         cursor.execute (s, p)
       else:
         cursor.execute (s)
-    except:
+    except Exception, e:
       cursor.close ()
-      raise Exceptions.ConnectionError, (errors.getException () [2], statement,
-          parameters)
+      raise Exceptions.ConnectionError(unicode(e), statement, parameters)
 
     return cursor
 

Modified: trunk/gnue-common/src/datasources/drivers/other/appserver.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/other/appserver.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/datasources/drivers/other/appserver.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -385,7 +385,7 @@
       self._session = self._sm.open (connectData)
 
     except errors.RemoteError, e:
-      if e.get_name() == 'AuthError':
+      if e.name == 'AuthError':
         raise Exceptions.LoginError, e.message
       else:
         raise

Modified: trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/datasources/drivers/sql/maxdb/Behavior.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -99,9 +99,9 @@
       session = sapdb.dbm.DBM (host, '', '',
                               "%s,%s" % (res ['_username'], res ['_password']))
 
-    except sapdb.dbm.CommunicationError, err:
+    except sapdb.dbm.CommunicationError, e:
       raise errors.AdminError, \
-          u_("Unable to establish session: %s") % errors.getException () [2]
+          u_("Unable to establish session: %s") % e
 
     try:
       result = session.cmd ('db_enum')

Modified: trunk/gnue-common/src/datasources/readgsd.py
===================================================================
--- trunk/gnue-common/src/datasources/readgsd.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/datasources/readgsd.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -228,9 +228,9 @@
             for filename in self.ARGUMENTS:
                 self._files.append(openResource(filename))
 
-        except IOError:
+        except IOError, e:
             raise GBaseApp.StartupError, \
-                u_("Unable to open input file: %s") % errors.getException()[2]
+                u_("Unable to open input file: %s") % e
 
 
         # --- Setup ouput file if requested -----------------------------------

Modified: trunk/gnue-common/src/definitions/GParser.py
===================================================================
--- trunk/gnue-common/src/definitions/GParser.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/definitions/GParser.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -148,7 +148,7 @@
     parser.parse (stream)
 
   except xml.sax.SAXParseException, e:
-    raise MarkupError, (errors.getException () [2], url, e.getLineNumber ())
+    raise MarkupError(uniocde(e), url, e.getLineNumber())
 
   object = dh.getRoot ()
 

Modified: trunk/gnue-common/src/logic/adapters/ecmascript.py
===================================================================
--- trunk/gnue-common/src/logic/adapters/ecmascript.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/logic/adapters/ecmascript.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -115,7 +115,7 @@
       self._cx.eval_script(self._realcode)
       
     except:
-      (group, name, message, detail) = errors.getException (1)
+      (group, name, message, detail) = errors.get_exception(tb_skip=1)
       if group == 'system':
            group = 'application'
       raise language.CompileError, (group, name, message, detail)
@@ -131,7 +131,7 @@
       return self._cx.call_fn(self._hname, ()) #args)
 
     except:
-      (group, name, message, detail) = errors.getException (1)
+      (group, name, message, detail) = errors.get_exception(tb_skip=1)
       if group == 'system':
           group = 'application'
       raise language.RuntimeError, (group, name, message, detail)
@@ -170,7 +170,7 @@
       self._cx.eval_script(self._realcode)
 
     except:
-      (group, name, message, detail) = errors.getException (1)
+      (group, name, message, detail) = errors.get_exception(tb_skip=1)
       if group == 'system':
         group = 'application'
       raise language.CompileError, (group, name, message, detail)
@@ -183,7 +183,7 @@
       return retval[0]
 
     except:
-      (group, name, message, detail) = errors.getException (1)
+      (group, name, message, detail) = errors.get_exception(tb_skip=1)
       if group == 'system':
         group = 'application'
       raise language.RuntimeError, (group, name, message, detail)

Modified: trunk/gnue-common/src/logic/adapters/python.py
===================================================================
--- trunk/gnue-common/src/logic/adapters/python.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/logic/adapters/python.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -28,7 +28,7 @@
 Language adapter plugin for Python.
 """
 
-from gnue.common.apps import errors
+from gnue.common.base import errors
 from gnue.common.logic import language
 from gnue.common.logic.adapters import Base
 
@@ -140,7 +140,7 @@
             compiled_code = compile(revised_code.encode('utf-8'),
                     '<%s>' % self.shortname.encode('utf-8'), 'exec')
         except:
-            (group, name, message, detail) = errors.getException(1)
+            (group, name, message, detail) = errors.get_exception(tb_skip=1)
             if group == 'system':
                 group = 'application'
             raise language.CompileError, (group, name, message, detail)
@@ -262,7 +262,7 @@
 
         except:
             # All others raise a RuntimeError
-            (group, name, message, detail) = errors.getException (2)
+            (group, name, message, detail) = errors.get_exception(tb_skip=2)
             if group == 'system':
                 group = 'application'
             raise language.RuntimeError, (group, name, message, detail)

Modified: trunk/gnue-common/src/rpc/client.py
===================================================================
--- trunk/gnue-common/src/rpc/client.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/rpc/client.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -28,7 +28,7 @@
 __all__ = ['attach', 'InvalidAdapter', 'AdapterInitializationError',
            'AdapterConfigurationError', 'ProgrammingError', 'AccessDeniedError']
 
-from gnue.common.apps import errors, plugin
+from gnue.common.base import errors, plugin
 
 # =============================================================================
 # Public functions
@@ -121,7 +121,6 @@
 
   import traceback
   import sys
-  from gnue.common.apps import errors
   import datetime
   
   if len (sys.argv) >= 2 and \
@@ -162,7 +161,7 @@
 
   except Exception, e:
     print "-" * 70
-    (group, name, message, detail) = errors.getException()
+    (group, name, message, detail) = errors.get_exception()
     print "Exception Group:", group
     print "Exception Name :", name
     print "Message        :", message

Modified: trunk/gnue-common/src/rpc/drivers/hessian/ClientAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/hessian/ClientAdapter.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/rpc/drivers/hessian/ClientAdapter.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -198,8 +198,8 @@
       (exType, exName, exMessage, exDetail) = e.message.split (u"\x91")
       raise errors.RemoteError, (exType, exName, exMessage, exDetail)
 
-    except socket.error:
-      raise errors.AdminError, errors.getException () [2]
+    except socket.error, e:
+      raise errors.AdminError(unicode(e))
 
     result = typeconv.rpc_to_python (result, self.__wrapProxy,
         client.InvalidParameter)

Modified: trunk/gnue-common/src/rpc/drivers/hessian/ServerAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/hessian/ServerAdapter.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/rpc/drivers/hessian/ServerAdapter.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -28,9 +28,9 @@
 import datetime
 
 from SimpleHessianServer import SimpleHessianServer
+from gnue.common.base import errors
 from gnue.common.rpc import server
 from gnue.common.rpc.drivers import Base
-from gnue.common.apps import errors
 from gnue.common.utils import http
 
 
@@ -268,8 +268,8 @@
     Process a Hessian request. Exceptions are reported by L{hessianlib.Fault}
     instances. Such an instance carries a string consisting of the group, name,
     message and traceback of the exception, separated by the unicode character
-    u'0x91' (see L{errors.getException}). The underlying connection will be
-    closed only if stated by the headers (e.g. 'Connection: close')
+    u'0x91'. The underlying connection will be closed only if stated by the
+    headers (e.g. 'Connection: close')
     """
 
     try:
@@ -284,7 +284,7 @@
       response = hessianlib.dumps (response, methodresponse = 1)
 
     except:
-      stack  = u"\x91".join (errors.getException ())
+      stack  = u"\x91".join (errors.get_exception())
       response = hessianlib.Fault (1, stack)
       response = hessianlib.dumps (response, methodresponse = 1)
 

Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/ClientAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/ClientAdapter.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/ClientAdapter.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -204,8 +204,8 @@
       (exType, exName, exMessage, exDetail) = e.faultString.split (u'\x91')
       raise errors.RemoteError, (exType, exName, exMessage, exDetail)
 
-    except socket.error:
-      raise errors.AdminError, errors.getException () [2]
+    except socket.error, e:
+      raise errors.AdminError(unicode(e))
 
     result = typeconv.rpc_to_python (result, self.__wrapProxy,
         client.InvalidParameter)

Modified: trunk/gnue-common/src/rpc/drivers/xmlrpc/ServerAdapter.py
===================================================================
--- trunk/gnue-common/src/rpc/drivers/xmlrpc/ServerAdapter.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/rpc/drivers/xmlrpc/ServerAdapter.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -26,11 +26,11 @@
 import SocketServer
 import typeconv
 import datetime
+from SimpleXMLRPCServer import SimpleXMLRPCServer
 
-from SimpleXMLRPCServer import SimpleXMLRPCServer
+from gnue.common.base import errors
 from gnue.common.rpc import server
 from gnue.common.rpc.drivers import Base
-from gnue.common.apps import errors
 from gnue.common.utils import http
 
 
@@ -268,8 +268,8 @@
     Process a XML-RPC request. Exceptions are reported by L{xmlrpclib.Fault}
     instances. Such an instance carries a string consisting of the group, name,
     message and traceback of the exception, separated by the unicode character
-    u'0x91' (see L{errors.getException}). The underlying connection will be
-    closed only if stated by the headers (e.g. 'Connection: close')
+    u'0x91'. The underlying connection will be closed only if stated by the
+    headers (e.g. 'Connection: close')
     """
 
     try:
@@ -284,7 +284,7 @@
       response = xmlrpclib.dumps (response, methodresponse = 1, allow_none = 1)
 
     except:
-      stack  = u'\x91'.join (errors.getException ())
+      stack  = u'\x91'.join (errors.get_exception())
       response = xmlrpclib.Fault (1, stack)
       response = xmlrpclib.dumps (response, methodresponse = 1)
 

Modified: trunk/gnue-common/src/utils/plugin.py
===================================================================
--- trunk/gnue-common/src/utils/plugin.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-common/src/utils/plugin.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -89,7 +89,7 @@
             message = u_("Cannot load plugin '%s'") % self.name
             detail = u_("The following plugins failed:\n")
             for (name, exc) in self.exceptions.items():
-                detail += "* %s: %s: %s" % (name, exc[1], exc[2])
+                detail += u"* %s: %s" % (name, exc)
         else:
             message = u_("Cannot find plugin '%s'") % self.name
             detail = None
@@ -236,8 +236,8 @@
 
     try:
         mod = __import__(base, None, None, '*')
-    except:
-        __failed[base] = errors.get_exception()
+    except Exception, e:
+        __failed[base] = e
         return {base: __failed[base]}
 
     if hasattr(mod, '__noplugin__'):
@@ -250,8 +250,8 @@
             if try_to_init and hasattr(mod, '__initplugin__'):
                 try:
                     mod.__initplugin__()
-                except:
-                    __failed[base] = errors.get_exception()
+                except Exception, e:
+                    __failed[base] = e
                     return {base: __failed[base]}
             return {base: mod}
 
@@ -277,8 +277,8 @@
 
     try:
         mod = __import__(base, None, None, '*')
-    except:
-        __failed[base] = errors.get_exception()
+    except Exception, e:
+        __failed[base] = e
         return {base: __failed[base]}
 
     if hasattr(mod, '__noplugin__'):
@@ -290,8 +290,8 @@
         if hasattr(mod, '__initplugin__'):
             try:
                 mod.__initplugin__()
-            except:
-                __failed[base] = errors.get_exception()
+            except Exception, e:
+                __failed[base] = e
                 return {base: __failed[base]}
         return mod
 
@@ -318,8 +318,8 @@
 
     try:
         mod = __import__(base, None, None, '*')
-    except:
-        __failed[base] = errors.get_exception()
+    except Exception, e:
+        __failed[base] = e
         return {base: __failed[base]}
 
     if hasattr(mod, '__noplugin__'):
@@ -339,8 +339,8 @@
         mod = __import__(base + '.' + name, None, None, '*')
     except ImportError:
         pass
-    except:
-        __failed[base + '.' + name] = errors.get_exception()
+    except Exception, e:
+        __failed[base + '.' + name] = e
         return {base + '.' + name: __failed[base + '.' + name]}
     else:
         return __first(base + '.' + name, identifier)
@@ -372,7 +372,7 @@
             if isinstance(iresult, ModuleType):
                 print "ok"
             else:
-                print iresult[1] + ": " + iresult[2]
+                print unicode(iresult)
 
     elif sys.argv[1] == 'test':
 

Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py	2009-10-02 13:06:16 UTC (rev 9922)
+++ trunk/gnue-forms/src/GFInstance.py	2009-10-02 15:29:26 UTC (rev 9923)
@@ -289,8 +289,8 @@
             form = self.__load(filehandle, None, True)
             filehandle.close()
             return form
-        except IOError:
-            raise FileOpenError, errors.getException()[2]
+        except IOError, e:
+            raise FileOpenError(unicode(e))
 
     # -------------------------------------------------------------------------
 
@@ -337,8 +337,8 @@
 
             return form
 
-        except IOError:
-            raise FileOpenError, errors.getException()[2]
+        except IOError, e:
+            raise FileOpenError(uniocde(e))
 
     # -------------------------------------------------------------------------
 
@@ -389,14 +389,13 @@
     # Show an exception
     # -------------------------------------------------------------------------
 
-    def show_exception(self, group=None, name=None, message=None, detail=None):
+    def show_exception(self, group, name, message, detail):
         """
-        This function shows the last exception raised.
+        This function shows the given exception.
 
         The exact way of showing the message depends on the exception group.
         """
-        if (group, name, message, detail) == (None, None, None, None):
-            (group, name, message, detail) = errors.getException()
+
         if group == 'user':
             self._uiinstance._ui_show_error_(message)
         else:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.