[Zope-Checkins] CVS: Zope/lib/python/OFS - Image.py:1.150
jeremy at zope.com
Wed Feb 25 10:45:48 EST 2004
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv7285
Use new Connection add() method instead of assigning _p_jar.
We'd like to deprecate explanation manipulation of a Persistent
object's _p_jar attribute. Also use less obscure _p_deactivate()
Revise comments and add assertions that object is stored and ghosted.
=== Zope/lib/python/OFS/Image.py 1.149 => 1.150 ===
--- Zope/lib/python/OFS/Image.py:1.149 Mon Jan 19 11:51:58 2004
+++ Zope/lib/python/OFS/Image.py Wed Feb 25 10:45:48 2004
@@ -480,9 +480,7 @@
# doing a sub-transaction commit.
- if jar is None:
+ if self._p_jar is None:
return Pdata(read(size)), size
@@ -491,31 +489,29 @@
# to front to minimize the number of database updates
# and to allow us to get things out of memory as soon as
+ next = None
while end > 0:
- if pos < n: pos=0 # we always want at least n bytes
+ pos = end-n
+ if pos < n:
+ pos = 0 # we always want at least n bytes
- # Woooop Woooop Woooop! This is a trick.
- # We stuff the data directly into our jar to reduce the
- # number of updates necessary.
+ # Create the object and assign it a next pointer
+ # in the same transaction, so that there is only
+ # a single database update for it.
+ data = Pdata(read(end-pos))
+ data.next = next
- # This is needed and has side benefit of getting
- # the thing registered:
- # Now make it get saved in a sub-transaction!
+ # Save the object so that we can release its memory.
+ # The object should be assigned an oid and be a ghost.
+ assert data._p_oid is not None
+ assert data._p_state == -1
- # Now make it a ghost to free the memory. We
- # don't need it anymore!
+ next = data
+ end = pos
return next, size
More information about the Zope-Checkins