commit-gnue
[Top][All Lists]
Advanced

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

r6241 - trunk/gnue-appserver/src/gld


From: johannes
Subject: r6241 - trunk/gnue-appserver/src/gld
Date: Thu, 2 Sep 2004 06:48:21 -0500 (CDT)

Author: johannes
Date: 2004-09-02 06:48:19 -0500 (Thu, 02 Sep 2004)
New Revision: 6241

Modified:
   trunk/gnue-appserver/src/gld/readgld.py
Log:
*) Don't ignore username and password from connections.conf
*) Changed from handleStartupError () to exceptions


Modified: trunk/gnue-appserver/src/gld/readgld.py
===================================================================
--- trunk/gnue-appserver/src/gld/readgld.py     2004-09-02 11:47:24 UTC (rev 
6240)
+++ trunk/gnue-appserver/src/gld/readgld.py     2004-09-02 11:48:19 UTC (rev 
6241)
@@ -25,20 +25,25 @@
 import os
 import whrandom
 
-from gnue.common.apps import GClientApp, i18n
+from gnue.common.apps import GClientApp, i18n, errors
 from gnue.common.utils.FileUtils import openResource
 from gnue.common.datasources import GDataSource, GConditions
 
 from gnue.appserver import VERSION
 from gnue.appserver.gld import GLParser
 
+from gnue.common.apps import GBaseApp
+
 # =============================================================================
 # Exceptions
 # =============================================================================
 
-class Error (gException):
+class StartupError (errors.UserError):
   pass
 
+class Error (errors.ApplicationError):
+  pass
+
 class ModuleNotFoundError (Error):
   def __init__ (self, module):
     msg = u_("Module '%s' not found in class repository.") % module
@@ -110,20 +115,15 @@
     self._args = [unicode (a, i18n.encoding) for a in self.ARGUMENTS]
 
     if not len (self._args):
-      self.handleStartupError (_("No input file specified."))
+      raise StartupError, _("No input file specified.")
 
-    try:
-      self._files = []
+    self._files = []
 
-      for filename in self._args:
-        self._files.append (openResource (filename))
+    for filename in self._args:
+      self._files.append (openResource (filename))
 
-    except IOError:
-      self.handleStartupError (u_("Unable to open input file %s.") % filename)
-
-
     if not self.OPTIONS ['connection']:
-      self.handleStartupError (_("No connection specified."))
+      raise StartupError, _("No connection specified.")
 
 
   # ---------------------------------------------------------------------------
@@ -133,9 +133,17 @@
   def __openDatasources (self):
     connection = self.connections.getConnection (self.OPTIONS ['connection'])
 
-    connection.parameters ['username'] = self.OPTIONS ['username'] or "gnue"
-    connection.parameters ['password'] = self.OPTIONS ['password'] or "gnue"
+    if not connection.parameters.has_key ('username'):
+      connection.parameters ['username'] = 'gnue'
+    if not connection.parameters.has_key ('password'):
+      connection.parameters ['password'] = 'gnue'
 
+    if self.OPTIONS ['username'] is not None:
+      connection.parameters ['username'] = self.OPTIONS ['username']
+
+    if self.OPTIONS ['password'] is not None:
+      connection.parameters ['password'] = self.OPTIONS ['password']
+
     self.connections.loginToConnection (connection)
 
     attributes = {'name'    : "dts_gnueModule",
@@ -210,31 +218,22 @@
     self.__checkOptions ()
     self.__openDatasources ()
 
-    try:
-      self.modules    = {}
-      self.classes    = {}
+    self.modules = {}
+    self.classes = {}
 
-      for item in range (len (self._files)):
-        print o(u_("Loading gld file '%s' ...") % self._args [item])
+    for item in range (len (self._files)):
+      print o(u_("Loading gld file '%s' ...") % self._args [item])
 
-        try:
-          schema = GLParser.loadFile (self._files [item])
-          schema.walk (self.__iterateObjects)
+      try:
+        schema = GLParser.loadFile (self._files [item])
+        schema.walk (self.__iterateObjects)
 
-        finally:
-          self._files [item].close ()
+      finally:
+        self._files [item].close ()
 
-    except Error, err:
-      print o(u_("Error: %s") % sys.exc_info () [1])
-      sys.exit (1)
+    self.updateRepository ()
 
-    except Exception:
-      raise
 
-    else:
-      self.updateRepository ()
-
-
   # ---------------------------------------------------------------------------
   # Iterate over all top level elements
   # ---------------------------------------------------------------------------
@@ -356,6 +355,7 @@
       rs = self._dtsModules.createResultSet (mc)
       if rs.firstRecord () is None:
         raise ModuleNotFoundError, (module)
+
       return rs.current.getField ('gnue_id')
 
 





reply via email to

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