[CMF-checkins] SVN: CMF/branches/2.1/C Issue #382: allow control of
customization of FS-based objects.
Tres Seaver
tseaver at palladion.com
Mon Apr 9 19:05:20 EDT 2007
Log message for revision 74070:
Issue #382: allow control of customization of FS-based objects.
Changed:
U CMF/branches/2.1/CHANGES.txt
U CMF/branches/2.1/CMFCore/FSObject.py
U CMF/branches/2.1/CMFCore/FSPropertiesObject.py
U CMF/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py
U CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py
U CMF/branches/2.1/CMFCore/tests/test_FSPropertiesObject.py
U CMF/branches/2.1/CMFCore/tests/test_FSPythonScript.py
U CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py
U CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py
U CMF/branches/2.1/CMFCore/tests/test_FSZSQLMethod.py
-=-
Modified: CMF/branches/2.1/CHANGES.txt
===================================================================
--- CMF/branches/2.1/CHANGES.txt 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CHANGES.txt 2007-04-09 23:05:19 UTC (rev 74070)
@@ -2,6 +2,10 @@
Bug Fixes
+ - Allow customization from DirectoryViews to be redirected into
+ alternate folders, and use manually-built clones.
+ (http://www.zope.org/Collectors/CMF/382)
+
- Use a utility, registered for
'Products.CMFDefault.interfaces.IHTMLScrubber', to perform scrubbing
of HTML; fall back to the old, hard-wired behavior.
Modified: CMF/branches/2.1/CMFCore/FSObject.py
===================================================================
--- CMF/branches/2.1/CMFCore/FSObject.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/FSObject.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -79,13 +79,15 @@
self._readFile(0)
security.declareProtected(ViewManagementScreens, 'manage_doCustomize')
- def manage_doCustomize(self, folder_path, RESPONSE=None):
+ def manage_doCustomize(self, folder_path, RESPONSE=None, \
+ root=None, obj=None):
"""Makes a ZODB Based clone with the same data.
Calls _createZODBClone for the actual work.
"""
- obj = self._createZODBClone()
+ if obj is None:
+ obj = self._createZODBClone()
parent = aq_parent(aq_inner(self))
# Preserve cache manager associations
@@ -118,7 +120,12 @@
id = obj.getId()
fpath = tuple( folder_path.split('/') )
- portal_skins = getUtility(ISkinsTool)
+ if root is None:
+ portal_skins = getUtility(ISkinsTool)
+ else:
+ portal_skins = root
+ if folder_path == '.':
+ fpath = ()
folder = portal_skins.restrictedTraverse(fpath)
if id in folder.objectIds():
# we cant catch the badrequest so
Modified: CMF/branches/2.1/CMFCore/FSPropertiesObject.py
===================================================================
--- CMF/branches/2.1/CMFCore/FSPropertiesObject.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/FSPropertiesObject.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -52,17 +52,22 @@
security.declarePrivate('manage_changePropertyTypes')
security.declareProtected(ViewManagementScreens, 'manage_doCustomize')
- def manage_doCustomize(self, folder_path, RESPONSE=None):
+ def manage_doCustomize(self, folder_path, RESPONSE=None, \
+ root=None, obj=None):
"""Makes a ZODB Based clone with the same data.
Calls _createZODBClone for the actual work.
"""
# Overridden here to provide a different redirect target.
- FSObject.manage_doCustomize(self, folder_path, RESPONSE)
+ FSObject.manage_doCustomize(self, folder_path, RESPONSE, \
+ root=root, obj=obj)
if RESPONSE is not None:
- fpath = tuple(folder_path.split('/'))
+ if folder_path == '.':
+ fpath = ()
+ else:
+ fpath = tuple(folder_path.split('/'))
folder = self.restrictedTraverse(fpath)
RESPONSE.redirect('%s/%s/manage_propertiesForm' % (
folder.absolute_url(), self.getId()))
Modified: CMF/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -20,6 +20,7 @@
from os.path import join as path_join
+from Acquisition import aq_base
from DateTime import DateTime
from OFS.Folder import Folder
from Products.StandardCacheManagers import RAMCacheManager
@@ -142,6 +143,35 @@
self.assertEqual( len( self.custom.objectIds() ), 1 )
self.failUnless( 'testDTML' in self.custom.objectIds() )
+ def test_customize_alternate_root( self ):
+
+ from OFS.Folder import Folder
+
+ self.root.other = Folder('other')
+
+ self.fsDTML.manage_doCustomize( folder_path='other', root=self.root )
+
+ self.failIf( 'testDTML' in self.custom.objectIds() )
+ self.failUnless( 'testDTML' in self.root.other.objectIds() )
+
+ def test_customize_fspath_as_dot( self ):
+
+ self.fsDTML.manage_doCustomize( folder_path='.' )
+
+ self.failIf( 'testDTML' in self.custom.objectIds() )
+ self.failUnless( 'testDTML' in self.skins.objectIds() )
+
+ def test_customize_manual_clone( self ):
+
+ from OFS.Folder import Folder
+
+ clone = Folder('testDTML')
+
+ self.fsDTML.manage_doCustomize( folder_path='custom', obj=clone )
+
+ self.failUnless( 'testDTML' in self.custom.objectIds() )
+ self.failUnless( aq_base(self.custom._getOb('testDTML')) is clone)
+
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
cache_id = 'gofast'
Modified: CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -22,6 +22,7 @@
from os.path import join as path_join
+from Acquisition import aq_base
from OFS.Folder import Folder
from Products.StandardCacheManagers import RAMCacheManager
@@ -193,6 +194,32 @@
self.assertEqual( len( self.custom.objectIds() ), 1 )
self.failUnless( 'testPT' in self.custom.objectIds() )
+ def test_customize_alternate_root( self ):
+
+ from OFS.Folder import Folder
+ self.root.other = Folder('other')
+
+ self.fsPT.manage_doCustomize( folder_path='other', root=self.root )
+
+ self.failIf( 'testPT' in self.custom.objectIds() )
+ self.failUnless( 'testPT' in self.root.other.objectIds() )
+
+ def test_customize_fspath_as_dot( self ):
+
+ self.fsPT.manage_doCustomize( folder_path='.' )
+
+ self.failIf( 'testPT' in self.custom.objectIds() )
+ self.failUnless( 'testPT' in self.skins.objectIds() )
+
+ def test_customize_manual_clone( self ):
+
+ clone = Folder('testPT')
+
+ self.fsPT.manage_doCustomize( folder_path='custom', obj=clone )
+
+ self.failUnless( 'testPT' in self.custom.objectIds() )
+ self.failUnless( aq_base(self.custom._getOb('testPT')) is clone )
+
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
cache_id = 'gofast'
Modified: CMF/branches/2.1/CMFCore/tests/test_FSPropertiesObject.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSPropertiesObject.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/tests/test_FSPropertiesObject.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -1,5 +1,6 @@
import unittest
+from Acquisition import aq_base
from zope.component import getSiteManager
from Products.CMFCore.interfaces import ISkinsTool
@@ -84,7 +85,38 @@
self.assertEqual( len( custom.objectIds() ), 1 )
self.failUnless( 'test_props' in custom.objectIds() )
+ def test_manage_doCustomize_alternate_root( self ):
+ from OFS.Folder import Folder
+ custom, fsdir, fspo = self._makeContext( 'test_props'
+ , 'test_props.props')
+ self.root.other = Folder('other')
+
+ fspo.manage_doCustomize( folder_path='other', root=self.root )
+
+ self.failIf( 'test_props' in custom.objectIds() )
+ self.failUnless( 'test_props' in self.root.other.objectIds() )
+
+ def test_manage_doCustomize_fspath_as_dot( self ):
+ custom, fsdir, fspo = self._makeContext( 'test_props'
+ , 'test_props.props')
+ fspo.manage_doCustomize( folder_path='.' )
+
+ self.failIf( 'test_props' in custom.objectIds() )
+ self.failUnless( 'test_props' in self.root.portal_skins.objectIds() )
+
+ def test_manage_doCustomize_manual_clone( self ):
+ from OFS.Folder import Folder
+
+ custom, fsdir, fspo = self._makeContext( 'test_props'
+ , 'test_props.props')
+ clone = Folder('test_props')
+ fspo.manage_doCustomize( folder_path='custom', obj=clone )
+
+ self.failUnless( 'test_props' in custom.objectIds() )
+ self.failUnless( aq_base(custom._getOb('test_props')) is clone )
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite( FSPOTests ),
Modified: CMF/branches/2.1/CMFCore/tests/test_FSPythonScript.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSPythonScript.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/tests/test_FSPythonScript.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -24,6 +24,7 @@
from thread import start_new_thread
from time import sleep
+from Acquisition import aq_base
from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
from Products.StandardCacheManagers import RAMCacheManager
@@ -132,6 +133,35 @@
self.failUnless(isinstance(test6, CustomizedPythonScript))
self.assertEqual(test6.original_source, fsPS.read())
+ def test_customize_alternate_root( self ):
+
+ root, tool, custom, fsdir, fsPS = self._makeSkins()
+ root.other = Folder('other')
+
+ fsPS.manage_doCustomize( folder_path='other', root=root )
+
+ self.failIf( 'test6' in custom.objectIds() )
+ self.failUnless( 'test6' in root.other.objectIds() )
+
+ def test_customize_fspath_as_dot( self ):
+
+ root, tool, custom, fsdir, fsPS = self._makeSkins()
+
+ fsPS.manage_doCustomize( folder_path='.' )
+
+ self.failIf( 'test6' in custom.objectIds() )
+ self.failUnless( 'test6' in root.portal_skins.objectIds() )
+
+ def test_customize_manual_clone( self ):
+
+ root, tool, custom, fsdir, fsPS = self._makeSkins()
+ clone = Folder('test6')
+
+ fsPS.manage_doCustomize( folder_path='custom', obj=clone )
+
+ self.failUnless( 'test6' in custom.objectIds() )
+ self.failUnless( aq_base(custom._getOb('test6')) is clone )
+
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
root, tool, custom, fsdir, fsPS = self._makeSkins()
Modified: CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -20,6 +20,7 @@
import os
import re
+from Acquisition import aq_base
from zope.component import getSiteManager
from zope.testing.cleanup import cleanUp
@@ -213,6 +214,33 @@
self.assertEqual(_normalize_whitespace(target.document_src()),
_normalize_whitespace(_CUSTOMIZED_TEMPLATE_ZPT))
+ def test_customize_alternate_root( self ):
+ from OFS.Folder import Folder
+
+ self.root.other = Folder('other')
+
+ self.fsReST.manage_doCustomize(folder_path='other', root=self.root)
+
+ self.failIf('testReST' in self.custom.objectIds())
+ self.failUnless('testReST' in self.root.other.objectIds())
+
+ def test_customize_fpath_as_dot( self ):
+
+ self.fsReST.manage_doCustomize(folder_path='.')
+
+ self.failIf('testReST' in self.custom.objectIds())
+ self.failUnless('testReST' in self.skins.objectIds())
+
+ def test_customize_manual_clone( self ):
+ from OFS.Folder import Folder
+
+ clone = Folder('testReST')
+
+ self.fsReST.manage_doCustomize(folder_path='custom', obj=clone)
+
+ self.failUnless('testReST' in self.custom.objectIds())
+ self.failUnless(aq_base(self.custom._getOb('testReST')) is clone)
+
def test_customize_caching(self):
# Test to ensure that cache manager associations survive customizing
from Products.StandardCacheManagers import RAMCacheManager
Modified: CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -20,6 +20,7 @@
import os
import re
+from Acquisition import aq_base
from zope.component import getSiteManager
from zope.testing.cleanup import cleanUp
@@ -227,6 +228,37 @@
SecurityTest.tearDown(self)
_TemplateSwitcher.tearDown(self)
+ def test_customize_alternate_root( self ):
+ from OFS.Folder import Folder
+
+ self._setWhichTemplate('DTML')
+ self.root.other = Folder('other')
+
+ self.fsSTX.manage_doCustomize(folder_path='other', root=self.root)
+
+ self.failIf('testSTX' in self.custom.objectIds())
+ self.failUnless('testSTX' in self.root.other.objectIds())
+
+ def test_customize_fspath_as_dot( self ):
+ self._setWhichTemplate('DTML')
+
+ self.fsSTX.manage_doCustomize(folder_path='.')
+
+ self.failIf('testSTX' in self.custom.objectIds())
+ self.failUnless('testSTX' in self.skins.objectIds())
+
+ def test_customize_manual_clone( self ):
+ from OFS.Folder import Folder
+
+ clone = Folder('testSTX')
+
+ self._setWhichTemplate('DTML')
+
+ self.fsSTX.manage_doCustomize(folder_path='custom', obj=clone)
+
+ self.failUnless('testSTX' in self.custom.objectIds())
+ self.failUnless(aq_base(self.custom._getOb('testSTX')) is clone)
+
def test_customize_with_DTML( self ):
from OFS.DTMLDocument import DTMLDocument
from Products.CMFCore.FSSTXMethod import _CUSTOMIZED_TEMPLATE_DTML
Modified: CMF/branches/2.1/CMFCore/tests/test_FSZSQLMethod.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSZSQLMethod.py 2007-04-09 22:40:27 UTC (rev 74069)
+++ CMF/branches/2.1/CMFCore/tests/test_FSZSQLMethod.py 2007-04-09 23:05:19 UTC (rev 74070)
@@ -4,6 +4,7 @@
from os.path import join
+from Acquisition import aq_base
from OFS.Folder import Folder
from zope.component import getSiteManager
@@ -77,6 +78,35 @@
self.assertEqual( len( self.custom.objectIds() ), 1 )
self.failUnless( 'testsql' in self.custom.objectIds() )
+ def test_customize_alternate_root( self ):
+
+ from OFS.Folder import Folder
+
+ self.root.other = Folder('other')
+
+ self.fsZSQL.manage_doCustomize( folder_path='other', root=self.root )
+
+ self.failIf( 'testsql' in self.custom.objectIds() )
+ self.failUnless( 'testsql' in self.root.other.objectIds() )
+
+ def test_customize_fspath_as_dot( self ):
+
+ self.fsZSQL.manage_doCustomize( folder_path='.' )
+
+ self.failIf( 'testsql' in self.custom.objectIds() )
+ self.failUnless( 'testsql' in self.skins.objectIds() )
+
+ def test_customize_manual_clone( self ):
+
+ from OFS.Folder import Folder
+
+ clone = Folder('testsql')
+
+ self.fsZSQL.manage_doCustomize( folder_path='custom', obj=clone )
+
+ self.failUnless( 'testsql' in self.custom.objectIds() )
+ self.failUnless( aq_base(self.custom._getOb('testsql')) is clone )
+
def test_customize_properties(self):
# Make sure all properties are coming across
self.fsZSQL.manage_doCustomize( folder_path='custom' )
More information about the CMF-checkins
mailing list