[Zope-Checkins] CVS: ZODB3/ZODB/zodb4 - conversion.py:1.1.2.3
Fred L. Drake, Jr.
fred at zope.com
Fri Jan 30 12:32:13 EST 2004
Update of /cvs-repository/ZODB3/ZODB/zodb4
In directory cvs.zope.org:/tmp/cvs-serv25129
Modified Files:
Tag: zope3-zodb3-devel-branch
conversion.py
Log Message:
use a proxy object for each transaction to present the ZODB3 view on
the transaction; this will be responsible for the data record format
conversion as well
=== ZODB3/ZODB/zodb4/conversion.py 1.1.2.2 => 1.1.2.3 ===
--- ZODB3/ZODB/zodb4/conversion.py:1.1.2.2 Thu Jan 29 16:31:42 2004
+++ ZODB3/ZODB/zodb4/conversion.py Fri Jan 30 12:32:13 2004
@@ -37,3 +37,33 @@
def iterator(self):
return self
+
+ def __iter__(self):
+ baseiter = z4iterator.FileIterator.__iter__(self)
+ for txn in baseiter:
+ yield DataRecordConvertingTxn(txn)
+
+
+class DataRecordConvertingTxn(object):
+
+ def __init__(self, txn):
+ self._txn = txn
+ self.user = str8(txn.user)
+ self.description = str8(txn.description)
+
+ def __getattr__(self, name):
+ return getattr(self._txn, name)
+
+ def __iter__(self):
+ for record in iter(self._txn):
+ record.tid = record.serial
+ yield record
+
+
+def str8(s):
+ # convert unicode strings to 8-bit strings
+ if isinstance(s, unicode):
+ # Should we use UTF-8 or ASCII? Not sure.
+ return s.encode("ascii")
+ else:
+ return s
More information about the Zope-Checkins
mailing list