[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r7232 - trunk/gnue-appserver/src
From: |
johannes |
Subject: |
[gnue] r7232 - trunk/gnue-appserver/src |
Date: |
Sun, 20 Mar 2005 06:35:45 -0600 (CST) |
Author: johannes
Date: 2005-03-20 06:35:44 -0600 (Sun, 20 Mar 2005)
New Revision: 7232
Modified:
trunk/gnue-appserver/src/data.py
Log:
Use connection-methods for insert, update and delete. This is a speed
improvement of about 10% - 30%
Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py 2005-03-20 10:17:50 UTC (rev 7231)
+++ trunk/gnue-appserver/src/data.py 2005-03-20 12:35:44 UTC (rev 7232)
@@ -25,6 +25,7 @@
import string
import copy
+import weakref
from gnue.common.apps import errors
from gnue.common.datasources import GDataSource, GConditions, GConnections
@@ -521,16 +522,7 @@
return datasource
-# -----------------------------------------------------------------------------
-# Create an empty result set
-# -----------------------------------------------------------------------------
-def _createEmptyResultSet (connections, database, table, fields):
-
- content = {None: (table, None, None, fields)}
- datasource = _createDatasource (connections, database, content)
- return datasource.createEmptyResultSet ()
-
# -----------------------------------------------------------------------------
# Create a result set with data
# -----------------------------------------------------------------------------
@@ -611,6 +603,12 @@
self.__uuidType = gConfig ('uuidtype').lower ()
+ # Keep a weak reference to the backend connection and make sure we're
+ # logged in
+ self.__backend = weakref.ref (connections.getConnection (database))
+ connections.loginToConnection (self.__backend ())
+
+
# ---------------------------------------------------------------------------
# Create a recordset from a query
# ---------------------------------------------------------------------------
@@ -782,24 +780,16 @@
tables = self.__cache.dirtyTables ()
+ backend = self.__backend ()
+ recNo = 0
+
# first perform all inserts
for (table, row) in self.__inserted [:]:
+ recNo += 1
if self.__cache.status (table, row) == 'inserted':
fields = tables [table] [row]
- resultSet = _createEmptyResultSet (self.__connections,
- self.__database,
- table, fields.keys ())
- try:
- resultSet.insertRecord ()
- for (field, value) in fields.items ():
- resultSet.current.setField (field, value)
-
- resultSet.post ()
-
- finally:
- resultSet.close ()
-
+ backend.insert (table, fields, recNo)
self.__inserted.remove ((table, row))
if (table, row) in self.__confirmedInserts:
@@ -810,42 +800,20 @@
# second perform all updates
for (table, rows) in tables.items ():
for (row, fields) in rows.items ():
+ recNo += 1
status = self.__cache.status (table, row)
if status == 'changed':
- # TODO: gnue-common should provide a method for updating a record
- # without reading it first. Until that is done, we have to create a
- # temporary resultSet for every record we update
- resultSet = _find (self.__connections, self.__database, table, row,
- [u'gnue_id'] + fields.keys ())
-
- try:
- for (field, value) in fields.items ():
- resultSet.current.setField (field, value)
-
- resultSet.post ()
-
- finally:
- resultSet.close ()
-
+ backend.update (table, {'gnue_id': row}, fields, recNo)
self.__cache.makeClean (table, row)
# perform all deletes
for (table, row) in self.__deleted:
- # TODO: gnue-common should provide a method for deleting a record
- # without reading it first. Until that is done, we have to create a
- # temporary resultSet for every record we delete
- resultSet = _find (self.__connections, self.__database, table, row,
- [u'gnue_id'])
- try:
- resultSet.current.delete ()
- resultSet.post ()
-
- finally:
- resultSet.close ()
-
+ recNo += 1
+ backend.delete (table, {'gnue_id': row}, recNo)
self.__cache.remove (table, row)
+
self.__deleted = []
self.__confirmedDeletes = []
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r7232 - trunk/gnue-appserver/src,
johannes <=