[CMF-checkins] SVN: CMF/trunk/GenericSetup/ - added support for
path elements in 'filename' (snapshot contexts,
works already with other contexts)
Yvo Schubbe
y.2005- at wcm-solutions.de
Sun Nov 20 13:34:48 EST 2005
Log message for revision 40277:
- added support for path elements in 'filename' (snapshot contexts, works already with other contexts)
Changed:
U CMF/trunk/GenericSetup/context.py
U CMF/trunk/GenericSetup/tests/test_context.py
-=-
Modified: CMF/trunk/GenericSetup/context.py
===================================================================
--- CMF/trunk/GenericSetup/context.py 2005-11-20 16:35:06 UTC (rev 40276)
+++ CMF/trunk/GenericSetup/context.py 2005-11-20 18:34:48 UTC (rev 40277)
@@ -420,6 +420,13 @@
""" See IExportContext.
"""
+ if subdir is not None:
+ filename = '/'.join( ( subdir, filename ) )
+
+ sep = filename.rfind('/')
+ if sep != -1:
+ subdir = filename[:sep]
+ filename = filename[sep+1:]
folder = self._ensureSnapshotsFolder( subdir )
# TODO: switch on content_type
@@ -525,6 +532,13 @@
""" See IImportContext.
"""
+ if subdir is not None:
+ filename = '/'.join( ( subdir, filename ) )
+
+ sep = filename.rfind('/')
+ if sep != -1:
+ subdir = filename[:sep]
+ filename = filename[sep+1:]
try:
snapshot = self._getSnapshotFolder( subdir )
object = snapshot._getOb( filename )
Modified: CMF/trunk/GenericSetup/tests/test_context.py
===================================================================
--- CMF/trunk/GenericSetup/tests/test_context.py 2005-11-20 16:35:06 UTC (rev 40276)
+++ CMF/trunk/GenericSetup/tests/test_context.py 2005-11-20 18:34:48 UTC (rev 40277)
@@ -1010,6 +1010,9 @@
self.assertEqual( template.meta_type, DTMLDocument.meta_type )
self.assertEqual( template.read(), _HTML )
+ ctx.writeDataFile( 'sub1/%s2' % FILENAME, _HTML, CONTENT_TYPE)
+ self.assertEqual( len( sub1.objectIds() ), 2 )
+
def test_writeDataFile_nested_subdirs_html( self ):
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
@@ -1198,6 +1201,8 @@
, subdir=SUBDIR )
self.assertEqual( ctx.readDataFile( FILENAME, SUBDIR ), printable )
+ self.assertEqual( ctx.readDataFile( '%s/%s' % (SUBDIR, FILENAME) ),
+ printable )
def test_getLastModified_nonesuch( self ):
More information about the CMF-checkins
mailing list