[CMF-checkins] SVN: CMF/branches/1.5/C CMFDefault.Portal:
deprecated 'manage_addCMFSite'.
Tres Seaver
tseaver at palladion.com
Wed Oct 19 09:43:56 EDT 2005
Log message for revision 39512:
CMFDefault.Portal: deprecated 'manage_addCMFSite'.
Changed:
U CMF/branches/1.5/CHANGES.txt
U CMF/branches/1.5/CMFDefault/Portal.py
U CMF/branches/1.5/CMFDefault/__init__.py
U CMF/branches/1.5/CMFDefault/tests/test_Portal.py
-=-
Modified: CMF/branches/1.5/CHANGES.txt
===================================================================
--- CMF/branches/1.5/CHANGES.txt 2005-10-19 13:32:29 UTC (rev 39511)
+++ CMF/branches/1.5/CHANGES.txt 2005-10-19 13:43:55 UTC (rev 39512)
@@ -41,6 +41,8 @@
Others
+ - CMFDefault.Portal: deprecated 'manage_addCMFSite'.
+
- Collectors #384: Added '__traceback_info__' to FSDTMLMethod's
call-stack etnry.
Modified: CMF/branches/1.5/CMFDefault/Portal.py
===================================================================
--- CMF/branches/1.5/CMFDefault/Portal.py 2005-10-19 13:32:29 UTC (rev 39511)
+++ CMF/branches/1.5/CMFDefault/Portal.py 2005-10-19 13:43:55 UTC (rev 39512)
@@ -79,8 +79,7 @@
title = ''
description = ''
- __ac_permissions__=( ( ManagePortal, ('manage_migrate_content',) )
- , ( AddPortalContent, () )
+ __ac_permissions__=( ( AddPortalContent, () )
, ( AddPortalFolders, () )
, ( ListPortalMembers, () )
, ( ReplyToItem, () )
@@ -104,77 +103,6 @@
"""
pass
- #
- # The following two methods allow conversion of portal content from
- # PTK version 0.7.1.
- # DO NOT REMOVE!!!
- #
- if 0:
- def manage_migrate_content(self, REQUEST):
- """
- Converts instances of Products.PTKBase.<content> to
- instances of Products.PTKDemo.<content>.
- """
- import Products.PTKBase.Document
- import Products.PTKBase.File
- import Products.PTKBase.Image
- import Products.PTKBase.Link
- import Products.PTKBase.NewsItem
- import NewsItem, Link, Document, File, Image
-
- migrations = {
- Products.PTKBase.Document.Document : Document.Document,
- Products.PTKBase.File.File : File.File,
- Products.PTKBase.Image.Image : Image.Image,
- Products.PTKBase.Link.Link : Link.Link,
- Products.PTKBase.NewsItem.NewsItem : NewsItem.NewsItem,
- }
-
- visited = []
- migrated = []
- self.__migrate_branches(migrations, self, migrated, visited)
- return 'Converted:\n%s\n\nDone.' % '\n'.join(migrated)
-
- def __migrate_branches(self, migrations, branch, migrated, visited):
- base = getattr(branch, 'aq_base', branch)
- if base in visited:
- # Don't visit again!
- return
- visited.append(base)
-
- try: changed = branch._p_changed
- except: changed = 1
- for id in branch.objectIds():
- obj = branch._getOb(id)
- obase = getattr(obj, 'aq_base', obj)
- klass = obase.__class__
- if migrations.has_key(klass):
- # Replace this object.
- changed = 1
- newob = migrations[klass](obase.id)
- newob.id = obase.id # This line activates obase.
- newob.__dict__.update(obase.__dict__)
- setattr(branch, id, newob)
- migrated.append(obj.absolute_url())
- elif hasattr(obase, 'objectIds'):
- # Enter a sub-branch.
- self.__migrate_branches(migrations, obj, migrated, visited)
- else:
- # Unload this object if it has not been changed.
- try:
- if obj._p_changed is None:
- obj._p_deactivate()
- except: pass
- if changed is None:
- # Unload this branch.
- object._p_deactivate()
-
- del visited[-1]
-
- else: # placeholder
- def manage_migrate_content( self, REQUEST ):
- pass
-
InitializeClass(CMFSite)
@@ -371,6 +299,14 @@
RESPONSE=None):
""" Adds a portal instance.
"""
+ from warnings import warn
+
+ warn("manage_addCMFSite is a deprecated way to create a CMF site; in the "
+ "future, please use CMFSetup's 'Configured CMF Site' (from the ZMI "
+ "add menu) or 'CMFSetup.factory.addConfiguredSite' (from Python). "
+ "manage_addCMFSite will be removed in CMF 2.0.",
+ DeprecationWarning, 2)
+
gen = PortalGenerator()
id = id.strip()
p = gen.create(self, id, create_userfolder)
Modified: CMF/branches/1.5/CMFDefault/__init__.py
===================================================================
--- CMF/branches/1.5/CMFDefault/__init__.py 2005-10-19 13:32:29 UTC (rev 39511)
+++ CMF/branches/1.5/CMFDefault/__init__.py 2005-10-19 13:43:55 UTC (rev 39512)
@@ -54,35 +54,6 @@
# Old name that some third-party packages may need.
ADD_CONTENT_PERMISSION = AddPortalContent
-
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-# N.B.: The following symbol controls whether we "inject" the
-# content types which formerly lived in CMFCore back into
-# it. While it is initially true (to allow existing portal
-# content to load), in a future release it will be set to
-# false; the behavior it governs will eventually be removed
-# altogether. YOU HAVE BEEN WARNED!!!
-#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-SUPPLY_DEPRECATED_PTK_BASE_ALIASES = 0
-
-if SUPPLY_DEPRECATED_PTK_BASE_ALIASES:
-
- # Get the old module names aliased into sys.modules...
- __module_aliases__ = ( ( 'Products.PTKBase.Document', Document )
- , ( 'Products.PTKBase.File', File )
- , ( 'Products.PTKBase.Image', Image )
- , ( 'Products.PTKBase.Link', Link )
- , ( 'Products.PTKBase.NewsItem', NewsItem )
- )
-
- # ...and make sure we can find them in PTKBase when we do
- # 'manage_migrate_content()'.
- Products.PTKBase.Document = Document
- Products.PTKBase.File = File
- Products.PTKBase.Image = Image
- Products.PTKBase.Link = Link
- Products.PTKBase.NewsItem = NewsItem
-
contentClasses = ( Document.Document
, File.File
, Image.Image
Modified: CMF/branches/1.5/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/1.5/CMFDefault/tests/test_Portal.py 2005-10-19 13:32:29 UTC (rev 39511)
+++ CMF/branches/1.5/CMFDefault/tests/test_Portal.py 2005-10-19 13:43:55 UTC (rev 39512)
@@ -26,14 +26,24 @@
from Acquisition import aq_base
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
+from Products.CMFCore.tests.base.testcase import WarningInterceptor
-class CMFSiteTests( SecurityRequestTest ):
+class CMFSiteTests( SecurityRequestTest
+ , WarningInterceptor
+ ):
- def _makeSite( self, id='testsite' ):
+ def setUp( self ):
+ SecurityRequestTest.setUp( self )
+ self._trap_warning_output()
+ def tearDown( self ):
+ self._free_warning_output()
+ SecurityRequestTest.tearDown( self )
+
+ def _makeSite( self, id='testsite'):
+
from Products.CMFDefault.Portal import manage_addCMFSite
-
manage_addCMFSite( self.root, id )
return getattr( self.root, id )
@@ -188,7 +198,22 @@
doc.edit( '<h1>Extra!</h1>' )
self.assertEqual( _getMetadata( catalog, rid ), 'Bar' )
+ def test_manage_addCMFSite_emits_DeprecationWarning( self ):
+ # This warning is recorded in *our* globals (stacklevel=2).
+ registry = globals().get("__warningregistry__")
+
+ if registry is not None:
+ registry.clear()
+
+ # Check that a warning was raised.
+ site = self._makeSite( 'emits_warning' )
+
+ self.assertEqual( len( registry ), 1 )
+ message, category, linenoe = registry.keys()[ 0 ]
+ self.failUnless( 'manage_addCMFSite' in message, message )
+ self.failUnless( category is DeprecationWarning, category )
+
def _getMetadata( catalog, rid, field='Title' ):
md = catalog.getMetadataForRID( rid )
return md[ field ]
More information about the CMF-checkins
mailing list