[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7246 - trunk/gnue-appserver/src
From: |
johannes |
Subject: |
[gnue] r7246 - trunk/gnue-appserver/src |
Date: |
Mon, 21 Mar 2005 12:52:47 -0600 (CST) |
Author: johannes
Date: 2005-03-21 12:52:46 -0600 (Mon, 21 Mar 2005)
New Revision: 7246
Modified:
trunk/gnue-appserver/src/data.py
Log:
Use connection.requery () to load existing records (reduces overhead of
resultSets)
Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py 2005-03-21 18:10:45 UTC (rev 7245)
+++ trunk/gnue-appserver/src/data.py 2005-03-21 18:52:46 UTC (rev 7246)
@@ -559,18 +559,6 @@
return cTree
-# -----------------------------------------------------------------------------
-# Create a result set containing only one row, identified by the gnue_id
-# -----------------------------------------------------------------------------
-
-def _find (connections, database, table, row, fields):
-
- content = {None: (table, None, None, fields)}
- condition = GConditions.buildConditionFromDict ({'gnue_id': row})
- resultSet = _createResultSet (connections, database, content, condition, [])
- resultSet.firstRecord ()
- return resultSet
-
# =============================================================================
# Session class
# =============================================================================
@@ -746,19 +734,10 @@
r._cache (u'gnue_id', row)
else:
# not yet cached, need to load from database
- resultSet = _find (self.__connections, self.__database, table, row,
- uncachedFields)
- try:
- if resultSet.current is None:
- return None
+ new = self.__backend ().requery (table, {u'gnue_id': row},
uncachedFields)
+ r = record (self.__cache, self.__connections, self.__database, table,
row)
+ r._fill (None, uncachedFields, new)
- r = record (self.__cache, self.__connections, self.__database, table,
- row)
- r._fill (None, uncachedFields, resultSet.current)
-
- finally:
- resultSet.close ()
-
return r
@@ -1560,6 +1539,7 @@
self.__database = database
self.__table = table
self.__row = row
+ self.__backend = None
# ---------------------------------------------------------------------------
@@ -1623,20 +1603,21 @@
return None
# Not found in cache, so get it from the db
- resultSet = _find (self.__connections, self.__database, self.__table,
- self.__row, [field])
- try:
- if resultSet.current is not None:
- value = resultSet.current [field]
- self.__cache.write (self.__table, self.__row, field, value, 0)
- return value
- else:
- return None
+ if self.__backend is None:
+ cons = self.__connections
+ self.__backend = weakref.ref (cons.getConnection (self.__database))
+ cons.loginToConnection (self.__backend ())
- finally:
- resultSet.close ()
+ new = self.__backend ().requery (self.__table, {u'gnue_id': self.__row},
+ [field])
+ value = new.get (field)
+ if new:
+ self.__cache.write (self.__table, self.__row, field, value, 0)
+ return value
+
+
# ---------------------------------------------------------------------------
# Put the value for a field
# ---------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7246 - trunk/gnue-appserver/src,
johannes <=