[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8463 - trunk/gnue-appserver/src
From: |
reinhard |
Subject: |
[gnue] r8463 - trunk/gnue-appserver/src |
Date: |
Mon, 15 May 2006 07:04:58 -0500 (CDT) |
Author: reinhard
Date: 2006-05-15 07:04:56 -0500 (Mon, 15 May 2006)
New Revision: 8463
Modified:
trunk/gnue-appserver/src/data.py
trunk/gnue-appserver/src/geasAuthentication.py
trunk/gnue-appserver/src/repository.py
Log:
Completely switched data.py to iterator.
Modified: trunk/gnue-appserver/src/data.py
===================================================================
--- trunk/gnue-appserver/src/data.py 2006-05-15 11:37:04 UTC (rev 8462)
+++ trunk/gnue-appserver/src/data.py 2006-05-15 12:04:56 UTC (rev 8463)
@@ -1231,7 +1231,6 @@
self.__remove = {}
self.__mergeWithCache (conditions)
- self.__current = None
self.__resultSet = _createResultSet (self.__connections, self.__database,
self.__content, conditions, order)
self.__rawdata = self.__resultSet.raw()
@@ -1290,54 +1289,6 @@
# ---------------------------------------------------------------------------
- # Return the next record
- # ---------------------------------------------------------------------------
-
- def nextRecord (self):
- """
- Returns the next record or None if nothing is left. If the query affected
- more than one table, the record for the main table (i.e. the table that is
- the root of all other references) is returned.
- """
-
- # if no more records are scheduled for addition, return the next usable
- # record from the backend
- if not len (self.__add):
- rec = self.__nextBackendRecord ()
- self.__current = None
- return rec
-
- else:
- if not self.__order:
- row = self.__add [0]
- self.__add.remove (row)
- self.__added += 1
- return record (self.__cache, self.__connections, self.__database,
- self.__getMasterTable (), row)
- else:
- row = self.__add [0]
- rec = self.__nextBackendRecord ()
-
- if rec is not None:
- rid = rec.getField (u'gnue_id')
- left = SortRecord (row, self.__getSortSequence (row))
- right = SortRecord (rid, self.__getSortSequence (rid))
-
- useAdd = cmp (left, right) <= 0
- else:
- useAdd = True
-
- if useAdd:
- self.__add.remove (row)
- self.__added += 1
- return record (self.__cache, self.__connections, self.__database,
- self.__getMasterTable (), row)
- else:
- self.__current = None
- return rec
-
-
- # ---------------------------------------------------------------------------
# Close the record set
# ---------------------------------------------------------------------------
@@ -1397,36 +1348,6 @@
# ---------------------------------------------------------------------------
- # Get the next record from the backend source
- # ---------------------------------------------------------------------------
-
- def __nextBackendRecord (self):
- """
- This function returns the next usable record from the backend. If there's
- a record in the queue from a previous access it will be used first. Every
- record retrieved from the backend will be checked if it is to be removed
- (listed in the remove queue).
-
- @return: record instance of the next usable backend record or None if no
- more records are available.
- """
-
- # If there is no record instance left from an earlier call, we fetch one
- if self.__current is None:
- try:
- self.__current = self.__buildRecords(self.__rawdata.next())
- except StopIteration:
- return None
-
- # Now, have a look if the instance has to be removed
- if self.__remove.has_key (self.__current._row):
- self.__current = None
- res = self.__nextBackendRecord ()
-
- return self.__current
-
-
- # ---------------------------------------------------------------------------
# Get the name of the master table of this recordset
# ---------------------------------------------------------------------------
@@ -1750,8 +1671,8 @@
class record:
"""
This class stands for a record in a database table. An instance of this class
- can be created via the recordset.nextRecord() methods, or by the
- connection.findRecord() method.
+ can be created via the recordset iterator, or by the connection.findRecord()
+ method.
"""
# ---------------------------------------------------------------------------
@@ -2041,11 +1962,12 @@
content = {u't0': (u'address_person', None, None, [u'address_name']),
u't1': (u'address_country', u't0', u'address_country',
[u'address_name'])}
- rs = c.query (content, None, [(u't0.address_name', True)])
+ rs = c.query (content, None, [{'name': u't0.address_name'}])
print 'Ok'
- print 'recordset.nextRecord ...',
- r = rs.nextRecord ()
+ print 'iterate to first record ...',
+ for r in rs:
+ break
print 'Ok'
print 'record.getField with prefetched data ...',
@@ -2064,8 +1986,9 @@
print 'record.getField of joined table with non-prefetched data ...',
print repr (r.getField (u'address_code'))
- print 'recordset.nextRecord ...',
- r = rs.nextRecord ()
+ print 'iterate to last record ...',
+ for r in rs:
+ pass
print 'Ok'
print 'record.getField with prefetched data ...',
@@ -2103,8 +2026,9 @@
['const', u'New Person']], None)
print 'Ok'
- print 'recordset.nextRecord ...',
- r = rs.nextRecord ()
+ print 'iterate to first record ...',
+ for r in rs:
+ break
print 'Ok'
print 'record.getField with prefetched data ...',
@@ -2159,7 +2083,7 @@
['eq', ['field', u'address_city'],
['const', u'New City']],
None)
- if rs.nextRecord () != None:
+ for r in rs:
raise Exception
print 'Ok'
Modified: trunk/gnue-appserver/src/geasAuthentication.py
===================================================================
--- trunk/gnue-appserver/src/geasAuthentication.py 2006-05-15 11:37:04 UTC
(rev 8462)
+++ trunk/gnue-appserver/src/geasAuthentication.py 2006-05-15 12:04:56 UTC
(rev 8463)
@@ -108,15 +108,14 @@
"for user '%(username)s'.") \
% {"numrec" : hits, "username": user}
- rec = resultSet.nextRecord ()
+ for rec in resultSet:
+ if rec.getField (u'gnue_password') != auth ['password']:
+ raise AuthError, u_("Invalid password for user '%s'") % user
- if rec.getField (u'gnue_password') != auth ['password']:
- raise AuthError, u_("Invalid password for user '%s'") % user
+ assert gDebug (1, "User '%s' logged in." % user)
- assert gDebug (1, "User '%s' logged in." % user)
+ session.tablelist = rec.getField (u'gnue_accesslist').split (',')
- session.tablelist = rec.getField (u'gnue_accesslist').split (',')
-
finally:
resultSet.close ()
Modified: trunk/gnue-appserver/src/repository.py
===================================================================
--- trunk/gnue-appserver/src/repository.py 2006-05-15 11:37:04 UTC (rev
8462)
+++ trunk/gnue-appserver/src/repository.py 2006-05-15 12:04:56 UTC (rev
8463)
@@ -380,15 +380,12 @@
resultSet = self._connection.query (contents, None, [{'name': u'gnue_id'}])
try:
- rec = resultSet.nextRecord ()
- while rec is not None:
+ for rec in resultSet:
row = result.setdefault (rec.getField (u'gnue_id'), {})
for field in fields:
row [field] = rec.getField (field)
- rec = resultSet.nextRecord ()
-
finally:
resultSet.close ()
@@ -866,8 +863,7 @@
resultSet = dataCon.query (contents, None, [{'name': u'gnue_id'}])
try:
- rec = resultSet.nextRecord ()
- while rec is not None:
+ for rec in ResultSet:
if master:
group = data.setdefault (rec.getField (master), [])
else:
@@ -880,8 +876,6 @@
group.append (row)
- rec = resultSet.nextRecord ()
-
finally:
resultSet.close ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8463 - trunk/gnue-appserver/src,
reinhard <=