[Checkins] SVN: Sandbox/shane/republish/zope.pipeline/ Added package metadata and test of autotemp.

Shane Hathaway shane at hathawaymix.org
Sat Feb 14 22:35:52 EST 2009


Log message for revision 96554:
  Added package metadata and test of autotemp.
  

Changed:
  _U  Sandbox/shane/republish/zope.pipeline/
  A   Sandbox/shane/republish/zope.pipeline/CHANGES.txt
  A   Sandbox/shane/republish/zope.pipeline/README.txt
  A   Sandbox/shane/republish/zope.pipeline/bootstrap.py
  A   Sandbox/shane/republish/zope.pipeline/buildout.cfg
  A   Sandbox/shane/republish/zope.pipeline/setup.py
  _U  Sandbox/shane/republish/zope.pipeline/src/
  U   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/requestsetup.py
  A   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/tests/
  A   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/tests/__init__.py
  U   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py
  A   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/
  A   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/__init__.py
  A   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt
  A   Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/tests.py

-=-

Property changes on: Sandbox/shane/republish/zope.pipeline
___________________________________________________________________
Added: svn:ignore
   + develop-eggs
bin
parts
.installed.cfg
coverage


Added: Sandbox/shane/republish/zope.pipeline/CHANGES.txt
===================================================================
--- Sandbox/shane/republish/zope.pipeline/CHANGES.txt	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/CHANGES.txt	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1,8 @@
+CHANGES
+=======
+
+0.1 (unreleased)
+----------------
+
+- New package derived from zope.publisher and zope.app.publisher.
+

Added: Sandbox/shane/republish/zope.pipeline/README.txt
===================================================================
--- Sandbox/shane/republish/zope.pipeline/README.txt	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/README.txt	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1,3 @@
+
+Zope object publisher based on a WSGI pipeline
+

Added: Sandbox/shane/republish/zope.pipeline/bootstrap.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/bootstrap.py	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/bootstrap.py	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 96548 2009-02-14 21:07:51Z shane $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+                     ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+    cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+    os.P_WAIT, sys.executable, sys.executable,
+    '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+    dict(os.environ,
+         PYTHONPATH=
+         ws.find(pkg_resources.Requirement.parse('setuptools')).location
+         ),
+    ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)

Added: Sandbox/shane/republish/zope.pipeline/buildout.cfg
===================================================================
--- Sandbox/shane/republish/zope.pipeline/buildout.cfg	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/buildout.cfg	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1,24 @@
+[buildout]
+develop = .
+	  ../zope.publisher
+parts = test python coverage-test coverage-report
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = zope.pipeline [test]
+
+[python]
+recipe = zc.recipe.egg
+eggs = zope.pipeline
+interpreter = python
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = zope.pipeline
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')

Added: Sandbox/shane/republish/zope.pipeline/setup.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/setup.py	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/setup.py	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import os
+from setuptools import setup, find_packages
+
+#entry_points = """
+#[paste.app_factory]
+#main = zope.pipeline.entry:create_pipeline
+#"""
+
+setup(name='zope.pipeline',
+      version = '0.1dev',
+      url='http://pypi.python.org/pypi/zope.pipeline',
+      license='ZPL 2.1',
+      author='Zope Corporation and Contributors',
+      author_email='zope-dev at zope.org',
+      description="Zope object publisher based on a WSGI pipeline",
+      long_description=(open('README.txt').read()
+                        + '\n\n'
+                        + open('CHANGES.txt').read()),
+
+      #entry_points = entry_points,
+
+      packages=find_packages('src'),
+      package_dir = {'': 'src'},
+
+      namespace_packages=['zope',],
+      install_requires=['setuptools',
+                        'zope.publisher',
+                        'zope.interface',
+                        'zope.hookable',
+                        ],
+      extras_require=dict(
+          test = ['zope.testing'],
+          ),
+      include_package_data = True,
+
+      zip_safe = False,
+      )


Property changes on: Sandbox/shane/republish/zope.pipeline/src
___________________________________________________________________
Added: svn:ignore
   + zope.pipeline.egg-info


Modified: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/requestsetup.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/requestsetup.py	2009-02-15 00:01:29 UTC (rev 96553)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/requestsetup.py	2009-02-15 03:35:51 UTC (rev 96554)
@@ -49,7 +49,11 @@
         self.set_locale(request)
         self.set_skin(request)
 
-        return self.next_app(environ, start_response)
+        try:
+            return self.next_app(environ, start_response)
+        finally:
+            request.close()
+            del environ['zope.request']
 
     def set_locale(self, request):
         envadapter = IUserPreferredLanguages(request, None)

Added: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/tests/__init__.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/tests/__init__.py	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/apps/tests/__init__.py	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1 @@
+

Modified: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py	2009-02-15 00:01:29 UTC (rev 96553)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/autotemp.py	2009-02-15 03:35:51 UTC (rev 96554)
@@ -13,6 +13,8 @@
 ##############################################################################
 
 from cStringIO import StringIO
+import tempfile
+from zope.hookable import hookable
 
 bufsize = 8192
 
@@ -23,8 +25,10 @@
         self._f = f = StringIO()
         self._switched = False
         # delegate most methods
-        for m in ('read', 'seek', 'tell', 'close'):
-            setattr(self, m, getattr(f, m))
+        self.read = hookable(f.read)
+        self.seek = hookable(f.seek)
+        self.tell = hookable(f.tell)
+        self.close = hookable(f.close)
 
     def write(self, data):
         if not self._switched and self.tell() + len(data) >= self._threshold:
@@ -34,9 +38,12 @@
             f.seek(self.tell())
             self._f = f
             self._switched = True
-            # delegate all important methods
-            for m in ('write', 'read', 'seek', 'tell', 'close'):
-                setattr(self, m, getattr(f, m))
+            # 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)
+            self.write = f.write
         self._f.write(data)
 
     def copyfrom(self, src):

Added: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/__init__.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/__init__.py	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/__init__.py	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1 @@
+

Added: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/autotemp_test.txt	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1,78 @@
+
+Tests of autotemp.AutoTemporaryFile
+-----------------------------------
+
+This small module provides a way to use temporary files without paying a
+file I/O performance penalty when the temporary data is small.
+
+    >>> from zope.pipeline.autotemp import AutoTemporaryFile
+    >>> f = AutoTemporaryFile(threshold=1000)
+    >>> f.write('data')
+    >>> f.seek(0)
+    >>> f.read()
+    'data'
+
+Since only a little data has been written, the instance is still using a
+StringIO.
+
+    >>> f._switched
+    False
+
+Write enough data to make it use a TemporaryFile instead.
+
+    >>> f.seek(0)
+    >>> data = '0123456789' * 101
+    >>> write = f.write
+    >>> write(data)
+    >>> f.seek(0)
+    >>> f.read() == data
+    True
+    >>> f.tell()
+    1010
+    >>> f._switched
+    True
+
+It's OK to keep a reference to the write() method.
+
+    >>> write('x')
+    >>> f.write('y')
+    >>> write('z')
+    >>> f.seek(1010)
+    >>> f.read()
+    'xyz'
+
+It's OK to keep a reference to other methods like read().
+
+    >>> f = AutoTemporaryFile(threshold=2)
+    >>> read = f.read
+    >>> f.write('abc')
+    >>> f._switched
+    True
+    >>> f.seek(0)
+    >>> read()
+    'abc'
+
+Convenience methods
+-------------------
+
+AutoTemporaryFile has copyfrom() and copyto(), which copy in chunks
+to avoid swamping the RAM.
+
+Test of copyfrom():
+
+    >>> from cStringIO import StringIO
+    >>> source = StringIO('0123456789')
+    >>> temp = AutoTemporaryFile()
+    >>> temp.copyfrom(source)
+    >>> temp.seek(0)
+    >>> temp.read()
+    '0123456789'
+
+Test of copyto():
+
+    >>> dest = StringIO()
+    >>> temp.seek(0)
+    >>> temp.copyto(dest)
+    >>> dest.seek(0)
+    >>> dest.read()
+    '0123456789'

Added: Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/tests.py
===================================================================
--- Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/tests.py	                        (rev 0)
+++ Sandbox/shane/republish/zope.pipeline/src/zope/pipeline/tests/tests.py	2009-02-15 03:35:51 UTC (rev 96554)
@@ -0,0 +1,28 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Tests of this package"""
+
+import unittest
+
+from zope.testing import doctest
+
+def test_suite():
+    return unittest.TestSuite([
+        doctest.DocFileSuite(
+            'autotemp_test.txt',
+            optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
+    ])
+
+if __name__ == '__main__':
+    unittest.main()



More information about the Checkins mailing list