commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r7191 - trunk/gnue-common/src/datasources/drivers/appserver/appse


From: reinhard
Subject: [gnue] r7191 - trunk/gnue-common/src/datasources/drivers/appserver/appserver
Date: Sat, 12 Mar 2005 07:49:58 -0600 (CST)

Author: reinhard
Date: 2005-03-12 07:49:58 -0600 (Sat, 12 Mar 2005)
New Revision: 7191

Modified:
   trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
   trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py
Log:
Moved implementation of insert, update and delete operations from RecordSet to
Connection to match new driver structure.


Modified: 
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py 
2005-03-12 13:45:46 UTC (rev 7190)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py 
2005-03-12 13:49:58 UTC (rev 7191)
@@ -120,7 +120,7 @@
 
 
   # ---------------------------------------------------------------------------
-  # Define the needed information to log in
+  # Implementations of virtual methods
   # ---------------------------------------------------------------------------
 
   def _getLoginFields (self):
@@ -143,16 +143,11 @@
 
     return result
 
-
   # ---------------------------------------------------------------------------
-  # Open a connection
-  # ---------------------------------------------------------------------------
 
   def _connect (self, connectData):
-
     self.__getSessionManager ()
     self.__updateFilters (connectData)
-
     try:
       self._sess_id = self._sm.open (connectData)
     except errors.RemoteError, e:
@@ -161,41 +156,47 @@
       else:
         raise
 
+  # ---------------------------------------------------------------------------
 
+  def _insert (self, table, newfields, recno):
+    f = newfields.copy ()
+    id = f.pop ('gnue_id')
+    self._sm.store (self._sess_id, table, [id], f.keys (), [f.values ()])
+
   # ---------------------------------------------------------------------------
-  # Update all fields of a record after update/inserts
+
+  def _update (self, table, oldfields, newfields, recno):
+    f = newfields
+    id = oldfields ['gnue_id']
+    self._sm.store (self._sess_id, table, [id], f.keys (), [f.values ()])
+
   # ---------------------------------------------------------------------------
 
+  def _delete (self, table, oldfields, recno):
+    id = oldfields ['gnue_id']
+    self._sm.delete (self._sess_id, table, [id])
+
+  # ---------------------------------------------------------------------------
+
   def _requery (self, table, oldfields, fields):
-
-    list = self._sm.load (self._sess_id, table, [oldfields ['gnue_id']],
-                          fields) [0]
+    id = oldfields ['gnue_id']
+    list = self._sm.load (self._sess_id, table, [id], fields) [0]
     result = {}
     for i in range (len (fields)):
       result [fields [i]] = list [i]
     return result
 
-
   # ---------------------------------------------------------------------------
-  # Commit active transaction
-  # ---------------------------------------------------------------------------
 
   def _commit (self):
-
     self._sm.commit (self._sess_id)
 
-
   # ---------------------------------------------------------------------------
-  # Rollback active transaction
-  # ---------------------------------------------------------------------------
 
   def _rollback (self):
     self._sm.rollback (self._sess_id)
 
-
   # ---------------------------------------------------------------------------
-  # Close connection
-  # ---------------------------------------------------------------------------
 
   def _close (self):
     if self._sm is not None:

Modified: 
trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py  
2005-03-12 13:45:46 UTC (rev 7190)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/RecordSet.py  
2005-03-12 13:49:58 UTC (rev 7191)
@@ -51,47 +51,6 @@
 
 
   # ---------------------------------------------------------------------------
-  # Delete
-  # ---------------------------------------------------------------------------
-
-  def _postDelete (self):
-    """
-    This function deletes the current record.
-    """
-
-    self.__sm.delete (self.__session_id,
-                      self.__classname,
-                      [self._fields ['gnue_id']])
-
-  # ---------------------------------------------------------------------------
-  # Insert
-  # ---------------------------------------------------------------------------
-
-  def _postInsert (self, fields):
-    """
-    This function updates the current record with the given fields.
-
-    @param fields: dictionary with the new fields and their values
-    """
-
-    self.__updateRecord (fields)
-
-
-  # ---------------------------------------------------------------------------
-  # Update
-  # ---------------------------------------------------------------------------
-
-  def _postUpdate (self, fields):
-    """
-    This function updates the current reocrd with the given fields.
-
-    @param fields: dictionary with the new fields and their values
-    """
-
-    self.__updateRecord (fields)
-
-
-  # ---------------------------------------------------------------------------
   # Call a server-side function
   # ---------------------------------------------------------------------------
 
@@ -212,28 +171,12 @@
 
     self.__updateFields ()
 
+    # Make sure that the gnue_id is included in the following insert operation.
+    # This flag does *not* mark the record itself as dirty, so it won't be
+    # included in the next post unless there are further modifications.
+    self._modifiedFlags ['gnue_id'] = True
 
-  # ---------------------------------------------------------------------------
-  # Update a record with the given fields
-  # ---------------------------------------------------------------------------
 
-  def __updateRecord (self, fields):
-    """
-    This function updates the record with the given fields dictionary where the
-    keys are the field names and the values are the field values. After calling
-    the store () function all fields will be reloaded so implicit changes will
-    be reflected in the _fields-dictionary.
-
-    @param fields: dictionary with fields (name = key, data = value)
-    """
-
-    self.__sm.store (self.__session_id,
-                     self.__classname,
-                     [self._fields ['gnue_id']],
-                     fields.keys (),
-                     [fields.values ()])
-
-
   # ---------------------------------------------------------------------------
   # Update all fields of a record after update/inserts
   # ---------------------------------------------------------------------------





reply via email to

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