commit-gnue
[Top][All Lists]
Advanced

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

gnue/gnue-common/src/dbdrivers/geas DBdriver.py


From: James Thompson
Subject: gnue/gnue-common/src/dbdrivers/geas DBdriver.py
Date: Wed, 19 Sep 2001 00:58:59 -0400

CVSROOT:        /cvs
Module name:    gnue
Changes by:     James Thompson <address@hidden> 01/09/19 00:58:58

Modified files:
        gnue-common/src/dbdrivers/geas: DBdriver.py 

Log message:
        GEAS driver work (not even close to finished)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/dbdrivers/geas/DBdriver.py.diff?cvsroot=OldCVS&tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: gnue/gnue-common/src/dbdrivers/geas/DBdriver.py
diff -u gnue/gnue-common/src/dbdrivers/geas/DBdriver.py:1.12 
gnue/gnue-common/src/dbdrivers/geas/DBdriver.py:1.13
--- gnue/gnue-common/src/dbdrivers/geas/DBdriver.py:1.12        Tue Sep 18 
00:34:36 2001
+++ gnue/gnue-common/src/dbdrivers/geas/DBdriver.py     Wed Sep 19 00:58:58 2001
@@ -26,7 +26,7 @@
 #
 # NOTES:
 # This implementation currently requires the use of python-orbit 
-# bindings.
+# bindings.  You MUST use orbit-python 0.3.0 or newer 
 #
 # HISTORY:
 #
@@ -35,8 +35,8 @@
 import string
 import types
 import md5
+import sys
 
-
 class GEAS_RecordSet(GDataObjects.RecordSet): 
   def _postChanges(self): 
     values = []
@@ -127,6 +127,7 @@
     # find the object server base object
     self.orb = CORBA.ORB_init(() , CORBA.ORB_ID)
     try:
+      print GConfig.get('GEASDIR')+"/var/run/geas-server.ior"
       self.ior = 
open(GConfig.get('GEASDIR')+"/var/run/geas-server.ior").readline()
     except (IOError), ex:
       GDebug.printMesg(1, "*** Error: ior file for geas was not found...  is 
geas running?")
@@ -143,8 +144,6 @@
         # TODO: (jcater)     allowGuestLogin = [0|1]
         # TODO: (jcater)     guestLogin = guest
         # TODO: (jcater)     allowBlankLogin = [0|1]
-
-        GDebug.printMesg(1,'Logging in as guest')
         self._databaseConnection = self._factory.guestLogin()
       else:
 
@@ -154,13 +153,8 @@
         # TODO: (jcater) this will have to do for now (even though, 
         # TODO: (jcater) IIRC, is does nothing to validate the user/pass
         # TODO: (jcater) supplied to it.)
-
-        GDebug.printMesg(1,'Logging in as user "%s"' % user)
         self._databaseConnection = self._factory.unsecureLogin(user,passwd)
 
-        ## Now make connection
-        #self.database.connect()
-
       self.triggerExtensions = TriggerExtensions(self._databaseConnection)
 
     except (GEAS.ServerError,
@@ -180,17 +174,31 @@
   def getLoginFields(self): 
     return [['_username', 'User Name',0],['_password', 'Password',1]]
 
+  def _buildQuery(self, conditions={}): 
+    GDebug.printMesg(7,'Implicit Fields: %s' % self._fieldReferences)
+    if len(self._fieldReferences): 
+            q = "SELECT %s FROM %s%s" % \
+           (string.join(self._fieldReferences.keys(),","), self.table, 
+            self._conditionToSQL(conditions))
+    else: 
+      q = "SELECT * FROM %s%s" % (self.table, self._conditionToSQL(conditions))
+
+    GDebug.printMesg(5,q)
+
+    return q
 
   def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None): 
-    try: 
-      cursor = self._dataConnection.cursor()
-      cursor.execute(self._buildQuery(conditions))
+    try:
+      pass
+      #cursor = self._dataConnection.newQuery()
+      
+      #cursor.execute(self._buildQuery(conditions))
     except self._DatabaseError, err: 
       raise GDataObjects.ConnectionError, err
-    rs = self._resultSetClass(self, cursor=cursor, masterRecordSet=None)
-    if readOnly: 
-      rs._readonly = readOnly
-    return rs
+    #rs = self._resultSetClass(self, cursor=cursor, masterRecordSet=None)
+    #if readOnly: 
+    #  rs._readonly = readOnly
+    #return rs
 
   def commit(self): 
     GDebug.printMesg (5,"GEAS database driver: commit()")
@@ -268,31 +276,9 @@
       
 
 
-class GEAS_DataObject_Object(GEAS_DataObject): 
-  def _buildQuery(self, conditions={}): 
-    GDebug.printMesg(7,'Implicit Fields: %s' % self._fieldReferences)
-    if len(self._fieldReferences): 
-      q = "SELECT %s FROM %s%s" % \
-           (string.join(self._fieldReferences.keys(),","), self.table, 
-            self._conditionToSQL(conditions))
-    else: 
-      q = "SELECT * FROM %s%s" % (self.table, self._conditionToSQL(conditions))
-
-    GDebug.printMesg(5,q)
-
-    return q
 
-
-
-class GEAS_DataObject_SQL(GEAS_DataObject): 
-  def _buildQuery(self, conditions={}): 
-    # Obviously, this is in a pre-alpha state :)
-    return "select zipcode, city, state from zipcode order by zipcode desc"
-
-
-
 supportedDataObjects = { 
-  'object': GEAS_DataObject_Object
+  'object': GEAS_DataObject
 }
 
 
@@ -310,15 +296,8 @@
 try:
     import CORBA
     idlFiles=GConfig.get('GEASDIR')+"/share/idl/geas.idl"
-    print idlFiles
     GDebug.printMesg(1,"IDL being loaded from %s" % (idlFiles))
-    # FIXME: Temporary hack to make this run with both orbit-python 0.1.x
-    #        (uses load_idl) and 0.2.0 (uses _load_idl)
-    if CORBA.__dict__.has_key("_load_idl"):
-        CORBA._load_idl(idlFiles)    # this will remain
-    else:
-        CORBA.load_idl(idlFiles)     # this will go away
-    # FIXME: end temporary hack
+    CORBA._load_idl(idlFiles)
     import GEAS
     
 except ImportError,ex:
@@ -338,15 +317,17 @@
         self.objlist = {}
 
     def connect(self, host, dbname, user, passwd):
+        GDebug.printMesg(1,"GEAS driver initializing")     
+
         # find the object server base object
         self.orb = CORBA.ORB_init(() , CORBA.ORB_ID)
         try:
             self.ior = 
open(GConfig.get('GEASDIR')+"/var/run/geas-server.ior").readline()
         except (IOError), ex:
-            print "*** Error: ior file for geas was not found...  is geas 
running?"
-            print
+            GDebug.printMesg(0,"*** Error: ior file for geas was not found...  
is geas running?")
             sys.exit(1)
         self.factory = self.orb.string_to_object(self.ior)
+
         try:
             GDebug.printMesg(1,"Logging into geas as %s" % (user))
             if (user == 'guest') or (user == ''):
@@ -354,14 +335,13 @@
             else:
                # NOTE: this will change again
                 self.database = self.factory.unsecureLogin(user,passwd)
+
+            print "DBdriver.py", self.database
 
-            ## Now make connection
-            #self.database.connect()
             self.triggerExtensions = TriggerExtensions(self._dataConnection)
-        except (GEAS.ServerError,
-               GEAS.AuthenticationError),ex:
-            print "Failed to connect to database. Exiting."
-            print ex.detail;
+        except (GEAS.ServerError,GEAS.AuthenticationError),ex:
+            GDebug.printMesg(0,"Failed to connect to database. Exiting.")
+            GDebug.printMesg(0,ex.detail)
             sys.exit(0)
 
     def disconnect(self):



reply via email to

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