[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7366 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2
From: |
reinhard |
Subject: |
[gnue] r7366 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2 appserver/appserver |
Date: |
Thu, 14 Apr 2005 13:08:35 -0500 (CDT) |
Author: reinhard
Date: 2005-04-14 13:08:33 -0500 (Thu, 14 Apr 2005)
New Revision: 7366
Modified:
trunk/gnue-common/src/datasources/drivers/Base/Connection.py
trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
Log:
Return None on requery of non-existant record.
Modified: trunk/gnue-common/src/datasources/drivers/Base/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/Base/Connection.py
2005-04-14 18:01:35 UTC (rev 7365)
+++ trunk/gnue-common/src/datasources/drivers/Base/Connection.py
2005-04-14 18:08:33 UTC (rev 7366)
@@ -549,7 +549,8 @@
@param oldfields: Fieldname/Value dictionary of fields to find the existing
record (aka where-clause).
@param fields: List of field names to query.
- @return: Fieldname/Value dictionary with data fresh from the backend.
+ @return: Fieldname/Value dictionary with data fresh from the backend, or
+ None if no record was found.
"""
return {}
Modified: trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
2005-04-14 18:01:35 UTC (rev 7365)
+++ trunk/gnue-common/src/datasources/drivers/DBSIG2/Connection.py
2005-04-14 18:08:33 UTC (rev 7366)
@@ -457,16 +457,20 @@
statement = "SELECT %s FROM %s WHERE %s" % (string.join (fields, ', '),
table, where)
try:
- list = self.sql (statement, parameters) [0]
+ rows = self.sql (statement, parameters)
except self._driver.DatabaseError:
raise Exceptions.ConnectionError, errors.getException () [2]
- result = {}
- for i in range (len (fields)):
- if isinstance (list [i], StringType):
- result [fields [i]] = unicode (list [i], self._encoding)
- else:
- result [fields [i]] = list [i]
- return result
+ if len (rows):
+ row = rows [0]
+ result = {}
+ for i in range (len (fields)):
+ if isinstance (row [i], StringType):
+ result [fields [i]] = unicode (row [i], self._encoding)
+ else:
+ result [fields [i]] = row [i]
+ return result
+ else:
+ return None
# ---------------------------------------------------------------------------
Modified:
trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
===================================================================
--- trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
2005-04-14 18:01:35 UTC (rev 7365)
+++ trunk/gnue-common/src/datasources/drivers/appserver/appserver/Connection.py
2005-04-14 18:08:33 UTC (rev 7366)
@@ -187,11 +187,15 @@
def _requery (self, table, oldfields, fields):
id = oldfields [u'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
+ rows = self._sm.load (self._sess_id, table, [id], fields)
+ if len (rows):
+ row = rows [0]
+ result = {}
+ for i in range (len (fields)):
+ result [fields [i]] = list [i]
+ return result
+ else:
+ return None
# ---------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7366 - in trunk/gnue-common/src/datasources/drivers: Base DBSIG2 appserver/appserver,
reinhard <=