[Checkins] SVN: Products.GenericSetup/trunk/ Export content objects whose 'manage_FTPget' returns a custom iterator
Tres Seaver
tseaver at palladion.com
Wed Feb 23 12:12:12 EST 2011
Log message for revision 120550:
Export content objects whose 'manage_FTPget' returns a custom iterator
Iterator must have 'file' and 'size' properties, as with
Products.Archetypes.WebDAVSupport.PdataStreamIterator.
Fixes https://bugs.launchpad.net/bugs/722726
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/context.py
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
U Products.GenericSetup/trunk/Products/GenericSetup/version.txt
U Products.GenericSetup/trunk/docs/CHANGES.rst
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/context.py 2011-02-23 15:11:37 UTC (rev 120549)
+++ Products.GenericSetup/trunk/Products/GenericSetup/context.py 2011-02-23 17:12:11 UTC (rev 120550)
@@ -451,9 +451,16 @@
self._archive.addfile(info)
parents.pop()
- stream = StringIO( text )
- info = TarInfo( filename )
- info.size = len( text )
+ info = TarInfo(filename)
+ if isinstance(text, basestring):
+ stream = StringIO(text)
+ info.size = len(text)
+ else:
+ # Assume text is a an instance of a class like
+ # Products.Archetypes.WebDAVSupport.PdataStreamIterator,
+ # as in the case of ATFile
+ stream = text.file
+ info.size = text.size
info.mtime = time.time()
self._archive.addfile( info, stream )
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2011-02-23 15:11:37 UTC (rev 120549)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2011-02-23 17:12:11 UTC (rev 120550)
@@ -18,6 +18,7 @@
import logging
import os
+import tempfile
import time
from StringIO import StringIO
from tarfile import TarFile
@@ -44,7 +45,11 @@
pass
+class DummyPdataStreamIterator:
+
+ pass
+
class DirectoryImportContextTests( FilesystemTestBase
, ConformsToISetupContext
, ConformsToIImportContext
@@ -798,6 +803,26 @@
self._verifyTarballEntry( fileish, 'foo.txt', printable )
self._verifyTarballEntry( fileish, 'bar.txt', digits )
+ def test_writeDataFile_PdataStreamIterator( self ):
+
+ from string import printable
+
+ site = DummySite('site').__of__(self.app)
+ ctx = self._getTargetClass()( site )
+
+ fp = tempfile.TemporaryFile()
+ fp.write(printable)
+ fp.seek(0)
+ pData = DummyPdataStreamIterator()
+ pData.file = fp
+ pData.size = len(printable)
+ ctx.writeDataFile( 'foo.txt', pData, 'text/plain' )
+
+ fileish = StringIO( ctx.getArchive() )
+
+ self._verifyTarballContents( fileish, [ 'foo.txt' ] )
+ self._verifyTarballEntry( fileish, 'foo.txt', printable)
+
def test_writeDataFile_subdir( self ):
from string import printable
Modified: Products.GenericSetup/trunk/Products/GenericSetup/version.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/version.txt 2011-02-23 15:11:37 UTC (rev 120549)
+++ Products.GenericSetup/trunk/Products/GenericSetup/version.txt 2011-02-23 17:12:11 UTC (rev 120550)
@@ -1 +1 @@
-1.6.2
+1.6.2+
Modified: Products.GenericSetup/trunk/docs/CHANGES.rst
===================================================================
--- Products.GenericSetup/trunk/docs/CHANGES.rst 2011-02-23 15:11:37 UTC (rev 120549)
+++ Products.GenericSetup/trunk/docs/CHANGES.rst 2011-02-23 17:12:11 UTC (rev 120550)
@@ -4,6 +4,9 @@
1.6.3 (unreleased)
------------------
+- Export content objects whose 'manage_FTPget' returns a custom iterator
+ with 'file' and 'size' properties. https://bugs.launchpad.net/bugs/722726
+
- Property import: Fixed 'lines' and 'tokens' import.
Modifying sequences without adding new elements was broken.
More information about the checkins
mailing list