[Zope-Checkins] CVS: Products/DCOracle2/DCOracle2 - DCOracle2.py:1.97
Matthew T. Kromer
matt@zope.com
Fri, 25 Oct 2002 10:35:27 -0400
Update of /cvs-repository/Products/DCOracle2/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv658/DCOracle2
Modified Files:
DCOracle2.py
Log Message:
Check in Gene Cash's iter() support with a mild tweak for systems without
StopIteration defined.
=== Products/DCOracle2/DCOracle2/DCOracle2.py 1.96 => 1.97 ===
--- Products/DCOracle2/DCOracle2/DCOracle2.py:1.96 Thu Oct 24 11:16:44 2002
+++ Products/DCOracle2/DCOracle2/DCOracle2.py Fri Oct 25 10:35:26 2002
@@ -108,6 +108,14 @@
from string import split, join, upper, find
from version import VERSION
+#
+# PYTHON VERSION NOTES
+#
+# This code should be compatible with Python 1.5.2 and higher. When making
+# version-specific changes to the code, all attempts should be made to
+# attempt to prevent this from harming older versions of the Python interpeter.
+#
+
version = VERSION + "$Revision$" [11:-2]+" (dco2: %s %s)" % (
dco2.__version__, dco2.buildDefs)
@@ -123,6 +131,11 @@
DateConversion = None
+# For the next() idiom which is Python 2.2, there is no StopIteration in
+# earlier pythons
+if split(sys.version)[0] < '2.2.0':
+ StopIteration = IndexError
+
def registerDateConversion(x):
global DateConversion
DateConversion = x
@@ -835,6 +848,15 @@
self._mapproc = {}
self._nullmap = None
+ # support iteration over a cursor
+ def __iter__(self):
+ return self
+
+ def next(self):
+ x = self.fetchone()
+ if x == None:
+ raise StopIteration
+ return x
# NONAPI
def describe(self,raw=None):