[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/ Add 'IChunkedExportContext' interface, allowing RAM-efficient chunked
Tres Seaver
tseaver at palladion.com
Tue Aug 12 13:22:21 EDT 2008
Log message for revision 89744:
Add 'IChunkedExportContext' interface, allowing RAM-efficient chunked
writes of large files, and implement for 'DirectoryExportContext'.
(https://bugs.launchpad.net/zope-cmf/+bug/257365)
Changed:
U Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
U Products.GenericSetup/trunk/Products/GenericSetup/context.py
U Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py
U Products.GenericSetup/trunk/Products/GenericSetup/tests/conformance.py
U Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-08-12 17:19:59 UTC (rev 89743)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt 2008-08-12 17:22:20 UTC (rev 89744)
@@ -4,6 +4,10 @@
GenericSetup 1.5.0 (unreleased)
-------------------------------
+- Add 'IChunkedExportContext' interface, allowing RAM-efficient chunked
+ writes of large files, and implement for 'DirectoryExportContext'.
+ (https://bugs.launchpad.net/zope-cmf/+bug/257365)
+
- Provide default for dependencies when processing metadata.xml, to
avoid a KeyError.
(https://bugs.launchpad.net/zope-cmf/+bug/255301)
Modified: Products.GenericSetup/trunk/Products/GenericSetup/context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/context.py 2008-08-12 17:19:59 UTC (rev 89743)
+++ Products.GenericSetup/trunk/Products/GenericSetup/context.py 2008-08-12 17:22:20 UTC (rev 89744)
@@ -39,6 +39,7 @@
from Products.PythonScripts.PythonScript import PythonScript
from zope.interface import implements
+from interfaces import IChunkableExportContext
from interfaces import IExportContext
from interfaces import IImportContext
from interfaces import ISetupEnviron
@@ -265,7 +266,7 @@
class DirectoryExportContext( BaseContext ):
- implements(IExportContext)
+ implements(IChunkableExportContext)
security = ClassSecurityInfo()
@@ -274,10 +275,10 @@
BaseContext.__init__( self, tool, encoding )
self._profile_path = profile_path
- security.declareProtected( ManagePortal, 'writeDataFile' )
- def writeDataFile( self, filename, text, content_type, subdir=None ):
+ security.declareProtected( ManagePortal, 'openDataFile' )
+ def openDataFile( self, filename, content_type, subdir=None ):
- """ See IExportContext.
+ """ See IChunkableExportContext.
"""
if subdir is None:
prefix = self._profile_path
@@ -291,7 +292,14 @@
mode = content_type.startswith( 'text/' ) and 'w' or 'wb'
- file = open( full_path, mode )
+ return open( full_path, mode )
+
+ security.declareProtected( ManagePortal, 'writeDataFile' )
+ def writeDataFile( self, filename, text, content_type, subdir=None ):
+
+ """ See IExportContext.
+ """
+ file = self.openDataFile( filename, content_type, subdir )
file.write( text )
file.close()
Modified: Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py 2008-08-12 17:19:59 UTC (rev 89743)
+++ Products.GenericSetup/trunk/Products/GenericSetup/interfaces.py 2008-08-12 17:22:20 UTC (rev 89744)
@@ -164,6 +164,24 @@
"root" of the target.
"""
+class IChunkableExportContext( IExportContext ):
+
+ def openDataFile( filename, content_type, subdir=None ):
+
+ """ Open a datafile for writing into the specified location.
+
+ o 'filename' is the unqualified name of the file.
+
+ o 'content_type' is the MIMEtype of the file.
+
+ o 'subdir', if passed, is a path to a subdirectory / folder in
+ which to write the file; if not passed, write the file to the
+ "root" of the target.
+
+ o Return a writeable file-like object; the caller is responsible
+ for calling 'close' on it.
+ """
+
class IExportPlugin( IPseudoInterface ):
""" Signature for callables used to export portions of site configuration.
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/conformance.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/conformance.py 2008-08-12 17:19:59 UTC (rev 89743)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/conformance.py 2008-08-12 17:22:20 UTC (rev 89744)
@@ -45,6 +45,15 @@
verifyClass( IExportContext, self._getTargetClass() )
+class ConformsToIChunkableExportContext:
+
+ def test_IChunkableExportContext_conformance( self ):
+
+ from Products.GenericSetup.interfaces import IChunkableExportContext
+ from zope.interface.verify import verifyClass
+
+ verifyClass( IChunkableExportContext, self._getTargetClass() )
+
class ConformsToIStepRegistry:
def test_IStepRegistry_conformance( self ):
Modified: Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2008-08-12 17:19:59 UTC (rev 89743)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tests/test_context.py 2008-08-12 17:22:20 UTC (rev 89744)
@@ -34,6 +34,7 @@
from conformance import ConformsToISetupContext
from conformance import ConformsToIImportContext
from conformance import ConformsToIExportContext
+from conformance import ConformsToIChunkableExportContext
class DummySite( Folder ):
@@ -339,6 +340,7 @@
class DirectoryExportContextTests( FilesystemTestBase
, ConformsToISetupContext
, ConformsToIExportContext
+ , ConformsToIChunkableExportContext
):
_PROFILE_PATH = '/tmp/ECTTexts'
More information about the Checkins
mailing list