commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7810 - in trunk: gnue-common/src/datasources gnue-forms/src gnue


From: reinhard
Subject: [gnue] r7810 - in trunk: gnue-common/src/datasources gnue-forms/src gnue-navigator/src
Date: Tue, 9 Aug 2005 13:28:27 -0500 (CDT)

Author: reinhard
Date: 2005-08-09 13:28:25 -0500 (Tue, 09 Aug 2005)
New Revision: 7810

Modified:
   trunk/gnue-common/src/datasources/ConnectionTriggerObj.py
   trunk/gnue-common/src/datasources/Exceptions.py
   trunk/gnue-common/src/datasources/GConnections.py
   trunk/gnue-forms/src/GFInstance.py
   trunk/gnue-navigator/src/UIwin32.py
   trunk/gnue-navigator/src/UIwx.py
Log:
Cleanup, docstrings, comments, exception cleanup.


Modified: trunk/gnue-common/src/datasources/ConnectionTriggerObj.py
===================================================================
--- trunk/gnue-common/src/datasources/ConnectionTriggerObj.py   2005-08-09 
18:22:30 UTC (rev 7809)
+++ trunk/gnue-common/src/datasources/ConnectionTriggerObj.py   2005-08-09 
18:28:25 UTC (rev 7810)
@@ -20,20 +20,23 @@
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
 # $Id$
+"""
+Wrapper object for connections to be used in trigger namespace.
+"""
 
 __all__ = ['ConnectionTriggerObj']
 
 import types
 
+from gnue.common.apps import GDebug
 from gnue.common.definitions import GObjects
-from gnue.common.apps import GDebug
 
 
 # =============================================================================
 # Connection wrapper object
 # =============================================================================
 
-class ConnectionTriggerObj(GObjects.GObj): 
+class ConnectionTriggerObj (GObjects.GObj): 
   """
   Class that allows us to insert Connection objects into trigger namespaces
   """
@@ -45,21 +48,22 @@
   # Constructor
   # ---------------------------------------------------------------------------
 
-  def __init__(self, connection, name): 
-    self.name = name
+  def __init__ (self, connection, name): 
+
     self.__connection = connection
-    GObjects.GObj.__init__(self, type="ConnTrigObj")
+    self.name         = name
+    GObjects.GObj.__init__ (self, type = "ConnTrigObj")
     
     self._triggerGlobal = True
-    self._triggerFunctions={}
+    self._triggerFunctions = {}
                             
-    for method in dir(connection): 
-      function = getattr(connection,method)
-      if method[0] != '_' and method not in self._blockedMethods \
-          and type(function) == types.MethodType:
-        self._triggerFunctions[method] = {'function':function}
+    for method in dir (connection): 
+      function = getattr (connection,method)
+      if method [0] != '_' and method not in self._blockedMethods \
+          and type (function) == types.MethodType:
+        self._triggerFunctions [method] = {'function': function}
     
-    self._triggerProperties={'login': {'get':self.__getLogin}}
+    self._triggerProperties = {'login': {'get': self.__getLogin}}
         
 
   # ---------------------------------------------------------------------------
@@ -67,22 +71,23 @@
   # ---------------------------------------------------------------------------
 
   def __getLogin(self): 
-    return self.__connection.manager.getAuthenticatedUser(self.name)
 
+    return self.__connection.manager.getAuthenticatedUser (self.name)
 
+
 # =============================================================================
 # Add all connections to the namespace
 # =============================================================================
 
-def addAllConnections(connections, gobjNamespace): 
+def addAllConnections (connections, gobjNamespace): 
   """
   Adds all the connection names to the global trigger namespace
   """
 
-  for name in connections.getConnectionNames(): 
+  for name in connections.getConnectionNames (): 
     try: 
-      conn = connections.getConnection(name)
+      conn = connections.getConnection (name)
     except: 
-      gDebug(1,"Cannot add connection %s to trigger namespace" % name)
+      gDebug (1,"Cannot add connection %s to trigger namespace" % name)
       continue
-    gobjNamespace.constructTriggerObject(ConnectionTriggerObj(conn, name))
+    gobjNamespace.constructTriggerObject (ConnectionTriggerObj (conn, name))

Modified: trunk/gnue-common/src/datasources/Exceptions.py
===================================================================
--- trunk/gnue-common/src/datasources/Exceptions.py     2005-08-09 18:22:30 UTC 
(rev 7809)
+++ trunk/gnue-common/src/datasources/Exceptions.py     2005-08-09 18:28:25 UTC 
(rev 7810)
@@ -20,6 +20,9 @@
 # - Suite 330, Boston, MA 02111-1307, USA.
 #
 # $Id$
+"""
+Exceptions used in the database driver system.
+"""
 
 from gnue.common.apps import errors
 
@@ -28,30 +31,32 @@
 # Exceptions
 # =============================================================================
 
-class Error(errors.gException):
-  # Base exception
-  pass
+# -----------------------------------------------------------------------------
+# Login failed
+# -----------------------------------------------------------------------------
 
 class LoginError (errors.UserError):
-  # Raised when invalid login user/pass was provided
-  # Client should attempt to get better information and
-  # try again
-  pass
+  """
+  Login failed.
 
-class ConnectError(errors.AdminError):
-  # Raised when connection data is invalid (e.g., host not found, etc).
-  # Client should probably not attempt to relogin.  Exit gracefully
-  # with a reason.
+  Raised by the database drivers whenever connecting to the backend failed due
+  to bad authentication data. The user will be prompted for new login data and
+  can try again.
+  """
   pass
 
-class ProviderNotSupportedError(errors.AdminError):
-  # Raised when a datasource type is requested that the dbdriver
-  # does not support (e.g., not all dbdrivers support raw sql mode.)
-  pass
 
-class ObjectTypeNotAvailableError(errors.AdminError):
-  # Raised when a datasource type is requested that the dbdriver
-  # does not support (e.g., not all dbdrivers support raw sql mode.)
+# -----------------------------------------------------------------------------
+# Query type not available
+# -----------------------------------------------------------------------------
+
+class ObjectTypeNotAvailableError (errors.AdminError):
+  """
+  Query type not available.
+
+  A datasource requested a query with a type that is not supported by the
+  database driver.
+  """
   pass
 
 
@@ -214,9 +219,13 @@
 
 
 # -----------------------------------------------------------------------------
-#
+# Backend error
 # -----------------------------------------------------------------------------
 
-class ConnectionError(errors.AdminError):
-  # Generic error reading from the database connection
+class ConnectionError (errors.AdminError):
+  """
+  Backend error.
+
+  Raised whenever the database backend cannot execute what GNUe tells to do.
+  """
   pass

Modified: trunk/gnue-common/src/datasources/GConnections.py
===================================================================
--- trunk/gnue-common/src/datasources/GConnections.py   2005-08-09 18:22:30 UTC 
(rev 7809)
+++ trunk/gnue-common/src/datasources/GConnections.py   2005-08-09 18:28:25 UTC 
(rev 7810)
@@ -73,11 +73,7 @@
   """
   pass
 
-# -----------------------------------------------------------------------------
 
-LoginError = Exceptions.LoginError
-
-
 # =============================================================================
 # Connection manager class
 # =============================================================================

Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py  2005-08-09 18:22:30 UTC (rev 7809)
+++ trunk/gnue-forms/src/GFInstance.py  2005-08-09 18:28:25 UTC (rev 7810)
@@ -302,15 +302,6 @@
       for formObject in self._formsDictionary.values ():
         formObject.phaseInit ()
 
-    except Exceptions.ConnectError:
-      raise StartupError, \
-          u_("Unable to login to datasource: %s") % errors.getException () [2]
-
-    except Exceptions.ConnectionError:
-      raise StartupError, \
-          u_("Error while communicating with datasource: %s") \
-          % errors.getException () [2]
-
     gDebug (4, "Initializing user interface driver object")
     self._uiinstance.initialize ()
 

Modified: trunk/gnue-navigator/src/UIwin32.py
===================================================================
--- trunk/gnue-navigator/src/UIwin32.py 2005-08-09 18:22:30 UTC (rev 7809)
+++ trunk/gnue-navigator/src/UIwin32.py 2005-08-09 18:28:25 UTC (rev 7810)
@@ -341,24 +341,14 @@
       #instance.buildForm(form)
       instance.activate()
 
-    except GConnections.Error, mesg:
-      self.handleError(mesg)
-
     except IOError, mesg:
       self.handleError(_("Unable to open file\n\n     %s")%mesg)
 
-    except Exceptions.ConnectError, mesg:
-      self.handleError(\
-         _("Unable to login to datasource.\n\n       %s") %mesg)
-
     except Exceptions.ConnectionError, mesg:
       self.handleError(\
          _("Error while communicating with datasource.\n\n       %s") %mesg)
 
-    except Exceptions.Error, mesg:
-      self.handleError(mesg)
 
-
   def handleStartupError(self, errortext):
     print
     print '-' * 60

Modified: trunk/gnue-navigator/src/UIwx.py
===================================================================
--- trunk/gnue-navigator/src/UIwx.py    2005-08-09 18:22:30 UTC (rev 7809)
+++ trunk/gnue-navigator/src/UIwx.py    2005-08-09 18:28:25 UTC (rev 7810)
@@ -287,23 +287,13 @@
       #instance.buildForm(form)
       instance.activate()
 
-    except GConnections.Error, mesg:
-      self.handleError(mesg)
-
     except IOError, mesg:
       self.handleError(_("Unable to open file\n\n     %s")%mesg)
 
-    except Exceptions.ConnectError, mesg:
-      self.handleError(\
-         _("Unable to login to datasource.\n\n       %s") %mesg)
-
     except Exceptions.ConnectionError, mesg:
       self.handleError(\
          _("Error while communicating with datasource.\n\n       %s") %mesg)
 
-    except Exceptions.Error, mesg:
-      self.handleError(mesg)
-
   def setTitle(self, title):
     self.frame.SetTitle ("GNUe Navigator: %s (form)" % title )
 





reply via email to

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