[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r6494 - trunk/gnue-appserver/src
From: |
johannes |
Subject: |
r6494 - trunk/gnue-appserver/src |
Date: |
Thu, 14 Oct 2004 04:27:44 -0500 (CDT) |
Author: johannes
Date: 2004-10-14 04:27:43 -0500 (Thu, 14 Oct 2004)
New Revision: 6494
Modified:
trunk/gnue-appserver/src/data.py
trunk/gnue-appserver/src/geasInstance.py
trunk/gnue-appserver/src/geasSession.py
Log:
Perform validations only on dirty instances and modification-stamps are
properly set
Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py 2004-10-13 13:39:04 UTC (rev 6493)
+++ trunk/gnue-appserver/src/data.py 2004-10-14 09:27:43 UTC (rev 6494)
@@ -100,10 +100,10 @@
fields [field] = value
# Update state information of the row
- if self.rowState (table, row) is None:
+ if self.__getState (table, row) is None:
self.__setState (table, row, 'initializing')
- if dirty and self.rowState (table, row) == 'initialized':
+ if dirty and self.__getState (table, row) == 'initialized':
self.__setState (table, row, 'commitable')
@@ -207,7 +207,11 @@
if new_id is None:
return '' # row was inserted and deleted
else:
- return 'inserted'
+ rowState = self.__getState (table, row)
+ if rowState == 'commitable':
+ return 'inserted'
+ else:
+ return rowState
else:
if new_id is None:
return 'deleted'
@@ -260,7 +264,7 @@
checktype (table, UnicodeType)
checktype (row, UnicodeType)
- cState = self.rowState (table, row)
+ cState = self.__getState (table, row)
if cState is not None and cState == 'commitable':
raise StateChangeError, (table, row)
@@ -289,9 +293,13 @@
# Return the current state of a row
# ---------------------------------------------------------------------------
- def rowState (self, table, row):
+ def __getState (self, table, row):
"""
This function returns the current state of a row
+ @param table: name of the table to get state information for
+ @param row: gnue-id of the row to get state information for
+
+ @return: state information for the requested row
"""
checktype (table, UnicodeType)
@@ -569,9 +577,12 @@
if not self.__cache.has (table, row, field):
uncachedFields.append(field)
- if uncachedFields == [] or self.__cache.status (table, row) == 'inserted':
+ if uncachedFields == [] or \
+ self.__cache.status (table, row) in ['initializing', 'initialized',
+ 'inserted']:
# already cached, no need to load from database
r = record (self.__cache, self.__connections, self.__database, table,
row)
+ r._cache (u'gnue_id', row)
else:
# not yet cached, need to load from database
resultSet = _find (self.__connections, self.__database, table, row,
@@ -596,7 +607,7 @@
# first perform all inserts
for (table, row) in self.__inserted:
- if self.__cache.rowState (table, row) == 'commitable':
+ if self.__cache.status (table, row) == 'inserted':
fields = tables [table] [row]
resultSet = _createEmptyResultSet (self.__connections,
self.__database,
@@ -925,7 +936,16 @@
self.__cache.initialized (self.__table, self.__row)
+
+ # ---------------------------------------------------------------------------
+ # Get the state of the current record
+ # ---------------------------------------------------------------------------
+
def status (self):
+ """
+ This function is a pass-through to the cached record's state
+ """
+
return self.__cache.status (self.__table, self.__row)
Modified: trunk/gnue-appserver/src/geasInstance.py
===================================================================
--- trunk/gnue-appserver/src/geasInstance.py 2004-10-13 13:39:04 UTC (rev
6493)
+++ trunk/gnue-appserver/src/geasInstance.py 2004-10-14 09:27:43 UTC (rev
6494)
@@ -383,15 +383,7 @@
# Update instance-stamps (creation- or modification-date/user )
# ---------------------------------------------------------------------------
- def updateStamp (self):
- if self.__record.status () == 'inserted':
- creation = True
- elif self.__record.status () == 'changed':
- creation = False
-
- else:
- return
-
+ def updateStamp (self, creation = False):
(datefield, userfield) = [('gnue_modifydate', 'gnue_modifyuser'),
('gnue_createdate', 'gnue_createuser')][creation]
if self.has_key (datefield):
@@ -399,3 +391,14 @@
if self.has_key (userfield) and self.__session.user is not None:
self.__putValue (userfield, self.__session.user, False)
+
+
+ # ---------------------------------------------------------------------------
+ # Get the state of the instances record in the cache
+ # ---------------------------------------------------------------------------
+
+ def status (self):
+ """
+ """
+
+ return self.__record.status ()
Modified: trunk/gnue-appserver/src/geasSession.py
===================================================================
--- trunk/gnue-appserver/src/geasSession.py 2004-10-13 13:39:04 UTC (rev
6493)
+++ trunk/gnue-appserver/src/geasSession.py 2004-10-14 09:27:43 UTC (rev
6494)
@@ -404,15 +404,15 @@
table = classdef.table
record = self.__connection.insertRecord (table)
+ instance = geasInstance.geasInstance (self, self.__connection, record,
+ classdef)
if classdef.gnue_filter is not None:
fId = classdef.gnue_filter.gnue_id
fName = self.sm.classes.find (fId).fullName
- record.putField (fName, self.__filterValue (fId))
+ instance.put ([fName], [self.__filterValue (fId)])
- instance = geasInstance.geasInstance (self, self.__connection, record,
- classdef)
- instance.updateStamp ()
+ instance.updateStamp (True)
onInits = {}
for proc in classdef.procedures.values ():
@@ -473,19 +473,20 @@
if object_id:
instance = self.__findInstance (classdef, object_id, [])
new_object_id = object_id
+
else:
instance = self.__newInstance (classdef)
new_object_id = instance.get ([u'gnue_id']) [0]
instance.put (propertylist, data [i])
- if object_id:
- # TODO: this update of mod-stamps could be moved into data.py ?!
- instance.updateStamp ()
i += 1
result.append (new_object_id)
- self.__dirtyInstances [new_object_id] = instance
+ if instance.status () in ['changed', 'inserted']:
+ instance.updateStamp ()
+ self.__dirtyInstances [new_object_id] = instance
+
except:
if opControl:
self.__cancelOperation ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r6494 - trunk/gnue-appserver/src,
johannes <=