[Checkins] SVN: Products.GenericSetup/trunk/ Avoid using manage_FTP* on snapshot exports
Partick Gerken
cvs-admin at zope.org
Thu Jul 19 12:13:21 UTC 2012
Log message for revision 127353:
Avoid using manage_FTP* on snapshot exports
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/context.py
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
U Products.GenericSetup/trunk/docs/CHANGES.rst
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/context.py 2012-07-19 05:10:34 UTC (rev 127352)
+++ Products.GenericSetup/trunk/Products/GenericSetup/context.py 2012-07-19 12:13:17 UTC (rev 127353)
@@ -34,6 +34,7 @@
from OFS.Folder import Folder
from OFS.Image import File
from OFS.Image import Image
+from OFS.Image import Pdata
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
from Products.PythonScripts.PythonScript import PythonScript
from zope.interface import implements
@@ -641,13 +642,16 @@
except ( AttributeError, KeyError ):
return None
- try:
+ if isinstance(object, File):
+ # OFS File Object have only one way to access the raw
+ # data directly, __str__. The code explicitly forbids
+ # to store unicode, so str() is safe here
+ data = str(object)
+ else:
data = object.read()
- if isinstance(data, unicode):
- data = data.encode('utf-8')
- return data
- except AttributeError:
- return object.manage_FTPget()
+ if isinstance(data, unicode):
+ data = data.encode('utf-8')
+ return data
security.declareProtected( ManagePortal, 'getLastModified' )
def getLastModified( self, path ):
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2012-07-19 05:10:34 UTC (rev 127352)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2012-07-19 12:13:17 UTC (rev 127353)
@@ -1188,6 +1188,19 @@
self.assertEqual( ctx.readDataFile( FILENAME ), printable )
+ def test_readDataFile_Pdata( self ):
+
+ from string import printable
+ from OFS.Image import Pdata
+
+ SNAPSHOT_ID = 'readDataFile_Pdata'
+ FILENAME = 'pdata.txt'
+
+ site, tool, ctx = self._makeOne( SNAPSHOT_ID )
+ self._makeFile( tool, SNAPSHOT_ID, FILENAME, Pdata(printable) )
+
+ self.assertEqual( ctx.readDataFile( FILENAME ), printable )
+
def test_readDataFile_subdir( self ):
from string import printable
Modified: Products.GenericSetup/trunk/docs/CHANGES.rst
===================================================================
--- Products.GenericSetup/trunk/docs/CHANGES.rst 2012-07-19 05:10:34 UTC (rev 127352)
+++ Products.GenericSetup/trunk/docs/CHANGES.rst 2012-07-19 12:13:17 UTC (rev 127353)
@@ -5,6 +5,8 @@
------------------
- ZopePageTemplate handler: Fixed export encoding.
+- Avoid using manage_FTPGet on Snapshot exports. This messes
+ up the response.
1.7.1 (2012-02-28)
More information about the checkins
mailing list