[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7473 - in trunk/gnue-common/src/datasources: . drivers/Base
From: |
reinhard |
Subject: |
[gnue] r7473 - in trunk/gnue-common/src/datasources: . drivers/Base |
Date: |
Sat, 23 Apr 2005 07:49:10 -0500 (CDT) |
Author: reinhard
Date: 2005-04-23 07:49:09 -0500 (Sat, 23 Apr 2005)
New Revision: 7473
Modified:
trunk/gnue-common/src/datasources/GDataSource.py
trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
Log:
Made RecordSet and ResultSet more independent from DataSource.
Modified: trunk/gnue-common/src/datasources/GDataSource.py
===================================================================
--- trunk/gnue-common/src/datasources/GDataSource.py 2005-04-23 12:26:25 UTC
(rev 7472)
+++ trunk/gnue-common/src/datasources/GDataSource.py 2005-04-23 12:49:09 UTC
(rev 7473)
@@ -60,6 +60,7 @@
self.table = None
self.cache = 5
self.distinct = False
+ self.primarykeyseq = None
self.requery = True
self._connections = None
@@ -558,7 +559,9 @@
tablename = self.table,
rowidField = self._rowidField,
primarykeyFields = self._primarykeyFields,
+ primarykeySeq = self.primarykeyseq,
boundFields = self._fieldReferences.keys (),
+ requery = self.requery,
readonly = readOnly,
masterRecord = masterRecord,
masterPkFields = self._masterPkFields,
Modified: trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-23
12:26:25 UTC (rev 7472)
+++ trunk/gnue-common/src/datasources/drivers/Base/RecordSet.py 2005-04-23
12:49:09 UTC (rev 7473)
@@ -44,7 +44,9 @@
tablename = '',
rowidField = None,
primarykeyFields = [],
+ primarykeySeq = None,
boundFields = [],
+ requery = True,
readonly = False,
masterRecord = None,
masterPkFields = [],
@@ -64,9 +66,17 @@
generated by the backend, if available.
@param primarykeyFields: List of field names that make up a unique key, if
available.
+ @param primarykeySeq: If this is set to the name of a backend sequence,
+ the RecordSet calls the getSequence method of the Connection object to
+ fill the primarykeyField before posting a new record to the backend. If
+ primarykeySeq is given, the primarykeyFields may only contain a single
+ field name.
@param boundFields: List of fields to be included when posting changes to
the backend. All fields not in this list are considered unbound fields
and are not persistent.
+ @param requery: If this is set to True, the RecordSet reqeries its values
+ from the backend after posting, in case a backend trigger has changed
+ something.
@param readonly: True if the RecordSet is read only. If set, an attempt to
modify or delete this record raises an exception.
@param masterRecord: RecordSet instance of the master of this record, or
@@ -82,7 +92,9 @@
self.__tablename = tablename
self.__rowidField = rowidField
self.__primarykeyFields = primarykeyFields
+ self.__primarykeySeq = primarykeySeq
self.__boundFields = boundFields
+ self.__requery = requery
self.__readonly = readonly
self.__masterRecord = masterRecord
self.__masterPkFields = masterPkFields
@@ -360,7 +372,7 @@
# Requery this record
# ---------------------------------------------------------------------------
- def __requery (self, fields):
+ def __do_requery (self, fields):
newfields = self.__connection.requery (self.__tablename,
self.__wherefields (), fields)
@@ -403,17 +415,13 @@
self.__dataSource._beforeCommitDelete (self)
# Check for empty primary key and set with the sequence value if so
- # TODO: Move this to GDataSource
- ds = self.__dataSource
if self.__status in ['empty', 'inserted']:
- if hasattr (ds, 'primarykey') and \
- hasattr (ds, 'primarykeyseq'):
- if ds.primarykey and ',' not in ds.primarykey and \
- ds.primarykeyseq and \
- hasattr (self.__connection, 'getsequence') and \
- self.getField (ds.primarykey) is None:
- pk = self.__connection.getsequence (ds.primarykeyseq)
- self.setField (ds.primarykey, pk)
+ if len (self.__primarykeyFields) == 1 and \
+ self.getField (self.__primarykeyFields [0]) is None and \
+ self.__primarykeySeq is not None and \
+ hasattr (self.__connection, 'getsequence'):
+ pk = self.__connection.getsequence (self.__primarykeySeq)
+ self.setField (self.__primarykeyFields [0], pk)
# If we have a connection (i.e. we aren't static or unbound), do the post
if self.__connection is not None:
@@ -435,7 +443,7 @@
# Requery all the fields that are important for inserting details.
# A backend trigger could have e.g. generated a primary key.
if self.__detailLinkFlags:
- self.__requery (self.__detailLinkFlags.keys ())
+ self.__do_requery (self.__detailLinkFlags.keys ())
else:
self.__connection.update (self.__tablename, self.__wherefields (),
@@ -464,9 +472,9 @@
"""
# First, requery ourselves
- if self.__dataSource is not None and self.__dataSource.requery:
+ if self.__requery:
if self.__rowidField or self.__primarykeyFields:
- self.__requery (self.__boundFields)
+ self.__do_requery (self.__boundFields)
# Now, requery detail resultsets
for (dataSource, resultSet) in self._cachedDetailResultSets.items ():
Modified: trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-23
12:26:25 UTC (rev 7472)
+++ trunk/gnue-common/src/datasources/drivers/Base/ResultSet.py 2005-04-23
12:49:09 UTC (rev 7473)
@@ -45,7 +45,9 @@
tablename = None,
rowidField = None,
primarykeyFields = [],
+ primarykeySeq = None,
boundFields = [],
+ requery = True,
readonly = False,
masterRecord = None,
masterPkFields = [],
@@ -64,9 +66,16 @@
generated by the backend, if available.
@param primarykeyFields: List of field names that make up a unique key, if
available.
+ @param primarykeySeq: If this is set to the name of a backend sequence,
+ the getSequence method of the Connection object is called to fill the
+ primarykeyField before posting to the backend. If primarykeySeq is
+ given, the primarykeyFields may only contain a single field name.
@param boundFields: List of fields to be included when posting changes to
the backend. All fields not in this list are considered unbound fields
and are not persistent.
+ @param requery: If this is set to True, the ResultSet reqeries its values
+ from the backend after posting, in case a backend trigger has changed
+ something.
@param readonly: True if the ResultSet is read only. If set, an attempt to
insert, modify or delete any record in this RecordSet raises an
exception.
@@ -84,7 +93,9 @@
self.__tablename = tablename
self.__rowidField = rowidField
self.__primarykeyFields = primarykeyFields
+ self.__primarykeySeq = primarykeySeq
self.__boundFields = boundFields
+ self.__requery = requery
self.__readonly = readonly
self.__masterRecord = masterRecord
self.__masterPkFields = masterPkFields
@@ -199,7 +210,9 @@
tablename = self.__tablename,
rowidField = self.__rowidField,
primarykeyFields = self.__primarykeyFields,
+ primarykeySeq = self.__primarykeySeq,
boundFields = self.__boundFields,
+ requery = self.__requery,
readonly = self.__readonly,
masterRecord = self.__masterRecord,
masterPkFields = self.__masterPkFields,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7473 - in trunk/gnue-common/src/datasources: . drivers/Base,
reinhard <=