commit-gnue
[Top][All Lists]
Advanced

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

r5582 - trunk/gnue-common/src/datasources


From: reinhard
Subject: r5582 - trunk/gnue-common/src/datasources
Date: Tue, 30 Mar 2004 16:17:30 -0600 (CST)

Author: reinhard
Date: 2004-03-30 16:17:29 -0600 (Tue, 30 Mar 2004)
New Revision: 5582

Modified:
   trunk/gnue-common/src/datasources/GConnections.py
Log:
Use new plugin loader.


Modified: trunk/gnue-common/src/datasources/GConnections.py
===================================================================
--- trunk/gnue-common/src/datasources/GConnections.py   2004-03-30 22:11:52 UTC 
(rev 5581)
+++ trunk/gnue-common/src/datasources/GConnections.py   2004-03-30 22:17:29 UTC 
(rev 5582)
@@ -38,11 +38,10 @@
 
 from ConfigParser import *
 import sys, string, copy, netrc
-from gnue.common.apps import GDebug
+from gnue.common.apps import GDebug, plugin
 from gnue.common.datasources import Exceptions
 from gnue.common.datasources import GLoginHandler
-from gnue.common.datasources.drivers import DRIVERS as ALLDRIVERS, ALIASES as 
DRIVERALIASES
-from gnue.common.utils.FileUtils import openResource, dyn_import
+from gnue.common.utils.FileUtils import openResource
 import GLoginHandler
 
 class Error(gException):
@@ -234,33 +233,9 @@
     driver = parameters['provider'].lower().replace('/','.')
     behavior = parameters.get('behavior','').lower().replace('/','.')
 
-    try:
-      basedriver, extradriver =driver.split('.',1)
-      extradriver = "." + extradriver
-    except:
-      basedriver = driver
-      extradriver = ""
+    dbdriver = plugin.find (driver, 'gnue.common.datasources.drivers',
+                            'Connection')
 
-    path = []
-
-    dbdriver = None
-
-    basemodule = _find_base_driver(basedriver, ALLDRIVERS)
-    GDebug.printMesg(1,'Using %s as base driver for %s' %  (basemodule, 
driver))
-
-    if basemodule:
-      dbdriver = _get_dbdriver(basemodule + extradriver)
-
-    if not dbdriver:
-      tmsg = _("No database driver found for provider type '%s'") % driver
-      raise Exceptions.ProviderNotSupportedError, tmsg
-
-    if not hasattr(dbdriver,"Connection"):
-      tmsg = _("The database driver '%s' doesn't have a 'Connection' 
object.\n"+\
-               "It has to be updated to the new driver API. --- "+\
-               "Please contact a gnue developer.") % driver
-      raise Exceptions.ProviderNotSupportedError, tmsg
-
     try:
       conn = dbdriver.Connection(self, connection_name, parameters)
     except TypeError:
@@ -498,50 +473,3 @@
     for connection in self._openConnections.values ():
       connection.close()
     self._openConnections = {}
-
-
-#
-# Load the correct DBdriver from gnue/common/datasources/drivers/*/
-#
-
-def _find_base_driver (driver, modules, path=[]):
-  if driver in modules:
-    return 'gnue.common.datasources.drivers.' + string.join(path + 
[driver],'.')
-  elif DRIVERALIASES.has_key(driver) and DRIVERALIASES[driver] in modules:
-    return 'gnue.common.datasources.drivers.' + string.join(path + 
[DRIVERALIASES[driver]],'.')
-  else:
-    for module in modules:
-      GDebug.printMesg(5,"trying module: %s" % module)
-      try:
-        m = dyn_import ('gnue.common.datasources.drivers.' + string.join(path 
+ [module],'.')).DRIVERS
-        rs = _find_base_driver(driver, m, path + [module])
-        if rs:
-          return rs
-      except (AttributeError, ImportError), err:
-        pass
-        ##print "Not in " + 'gnue.common.datasources.drivers.' + 
string.join(path + [module],'.')
-      except AdapterNotInstalled:
-        GDebug.printMesg(1,'%s does not have all dependencies installed' % 
driver)
-
-
-def _get_dbdriver (driver):
-  dbdriver = None
-
-  try:
-    dbdriver = dyn_import("%s" % (driver))
-    dbdriver.Connection
-  except:
-    GDebug.printMesg(1,'%s is not a dbdriver' % ( driver))
-    try:
-      drivers = dyn_import("%s" % (driver)).DRIVERS
-      for d in drivers:
-        dbdriver = _get_dbdriver(driver + "." + d )
-        if dbdriver:
-          return dbdriver
-    except (ImportError, AttributeError):
-      GDebug.printMesg(1,'%s does not contain dbdrivers' % (driver))
-    except AdapterNotInstalled:
-      GDebug.printMesg(1,'%s does not have all dependencies installed' % 
driver)
-
-  return dbdriver
-





reply via email to

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