[Checkins] SVN: Sandbox/shane/republish/zope.pipeline/s We don't really need hookable here.
Shane Hathaway
shane at hathawaymix.org
Sat Feb 14 22:53:55 EST 2009
Log message for revision 96555:
We don't really need hookable here.
Changed:
U Sandbox/shane/republish/zope.pipeline/setup.py
U Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py
U Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt
-=-
Modified: Sandbox/shane/republish/zope.pipeline/setup.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/setup.py 2009-02-15 03:35:51 UTC (rev 96554)
+++ Sandbox/shane/republish/zope.pipeline/setup.py 2009-02-15 03:53:55 UTC (rev 96555)
@@ -40,7 +40,6 @@
install_requires=['setuptools',
'zope.publisher',
'zope.interface',
- 'zope.hookable',
],
extras_require=dict(
test = ['zope.testing'],
Modified: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py 2009-02-15 03:35:51 UTC (rev 96554)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py 2009-02-15 03:53:55 UTC (rev 96555)
@@ -14,7 +14,6 @@
from cStringIO import StringIO
import tempfile
-from zope.hookable import hookable
bufsize = 8192
@@ -24,25 +23,33 @@
self._threshold = threshold
self._f = f = StringIO()
self._switched = False
- # delegate most methods
- self.read = hookable(f.read)
- self.seek = hookable(f.seek)
- self.tell = hookable(f.tell)
- self.close = hookable(f.close)
+ def read(self, count=-1):
+ return self._f.read(count)
+
+ def seek(self, pos, mode=0):
+ self._f.seek(pos, mode)
+
+ def tell(self):
+ return self._f.tell()
+
+ def close(self):
+ self._f.close()
+
def write(self, data):
if not self._switched and self.tell() + len(data) >= self._threshold:
# convert to TemporaryFile
+ old = self._f
f = tempfile.TemporaryFile()
- f.write(self._f.getvalue())
- f.seek(self.tell())
+ f.write(old.getvalue())
+ f.seek(old.tell())
self._f = f
self._switched = True
- # re-delegate all important methods
- self.read.sethook(f.read)
- self.seek.sethook(f.seek)
- self.tell.sethook(f.tell)
- self.close.sethook(f.close)
+ # delegate to the file directly
+ self.read = f.read
+ self.seek = f.seek
+ self.tell = f.tell
+ self.close = f.close
self.write = f.write
self._f.write(data)
Modified: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt 2009-02-15 03:35:51 UTC (rev 96554)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt 2009-02-15 03:53:55 UTC (rev 96555)
@@ -76,3 +76,4 @@
>>> dest.seek(0)
>>> dest.read()
'0123456789'
+ >>> temp.close()
More information about the Checkins
mailing list