[CMF-checkins] SVN: CMF/trunk/CMFCore/ Issue #382: allow control of customization of FS-based objects.

Tres Seaver tseaver at palladion.com
Mon Apr 9 19:07:21 EDT 2007


Log message for revision 74071:
  Issue #382:  allow control of customization of FS-based objects.

Changed:
  U   CMF/trunk/CMFCore/FSObject.py
  U   CMF/trunk/CMFCore/FSPropertiesObject.py
  U   CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py
  U   CMF/trunk/CMFCore/tests/test_FSPageTemplate.py
  U   CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py
  U   CMF/trunk/CMFCore/tests/test_FSPythonScript.py
  U   CMF/trunk/CMFCore/tests/test_FSReSTMethod.py
  U   CMF/trunk/CMFCore/tests/test_FSSTXMethod.py
  U   CMF/trunk/CMFCore/tests/test_FSZSQLMethod.py

-=-
Modified: CMF/trunk/CMFCore/FSObject.py
===================================================================
--- CMF/trunk/CMFCore/FSObject.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/FSObject.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -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/trunk/CMFCore/FSPropertiesObject.py
===================================================================
--- CMF/trunk/CMFCore/FSPropertiesObject.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/FSPropertiesObject.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -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/trunk/CMFCore/tests/test_FSDTMLMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -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/trunk/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPageTemplate.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/tests/test_FSPageTemplate.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -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/trunk/CMFCore/tests/test_FSPropertiesObject.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -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/trunk/CMFCore/tests/test_FSPythonScript.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPythonScript.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/tests/test_FSPythonScript.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -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/trunk/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSReSTMethod.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/tests/test_FSReSTMethod.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -20,6 +20,7 @@
 import os
 import re
 
+from Acquisition import aq_base
 from zope.component import getSiteManager
 from zope.testing.cleanup import cleanUp
 
@@ -212,6 +213,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/trunk/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSSTXMethod.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/tests/test_FSSTXMethod.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -20,6 +20,7 @@
 import os
 import re
 
+from Acquisition import aq_base
 from zope.component import getSiteManager
 from zope.testing.cleanup import cleanUp
 
@@ -226,6 +227,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/trunk/CMFCore/tests/test_FSZSQLMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSZSQLMethod.py	2007-04-09 23:05:19 UTC (rev 74070)
+++ CMF/trunk/CMFCore/tests/test_FSZSQLMethod.py	2007-04-09 23:07:21 UTC (rev 74071)
@@ -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