[CMF-checkins] SVN: CMF/branches/tseaver-viewification/ Merge trunk
changes to viewification branch.
Tres Seaver
tseaver at palladion.com
Sat Nov 19 12:53:08 EST 2005
Log message for revision 40249:
Merge trunk changes to viewification branch.
Changed:
U CMF/branches/tseaver-viewification/CHANGES.txt
U CMF/branches/tseaver-viewification/CMFActionIcons/DEPENDENCIES.txt
D CMF/branches/tseaver-viewification/CMFActionIcons/Extensions/
D CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_all.py
U CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_exportimport.py
U CMF/branches/tseaver-viewification/CMFCalendar/Event.py
D CMF/branches/tseaver-viewification/CMFCalendar/Extensions/
D CMF/branches/tseaver-viewification/CMFCalendar/INSTALL.txt
U CMF/branches/tseaver-viewification/CMFCalendar/README.txt
U CMF/branches/tseaver-viewification/CMFCalendar/__init__.py
D CMF/branches/tseaver-viewification/CMFCalendar/tests/test_all.py
U CMF/branches/tseaver-viewification/CMFCalendar/utils.py
U CMF/branches/tseaver-viewification/CMFCore/ActionInformation.py
U CMF/branches/tseaver-viewification/CMFCore/ActionProviderBase.py
U CMF/branches/tseaver-viewification/CMFCore/CMFBTreeFolder.py
U CMF/branches/tseaver-viewification/CMFCore/CachingPolicyManager.py
U CMF/branches/tseaver-viewification/CMFCore/CatalogTool.py
U CMF/branches/tseaver-viewification/CMFCore/ContentTypeRegistry.py
U CMF/branches/tseaver-viewification/CMFCore/FSMetadata.py
U CMF/branches/tseaver-viewification/CMFCore/PortalFolder.py
U CMF/branches/tseaver-viewification/CMFCore/PortalObject.py
U CMF/branches/tseaver-viewification/CMFCore/Skinnable.py
U CMF/branches/tseaver-viewification/CMFCore/TypesTool.py
U CMF/branches/tseaver-viewification/CMFCore/WorkflowTool.py
U CMF/branches/tseaver-viewification/CMFCore/__init__.py
U CMF/branches/tseaver-viewification/CMFCore/browser/meta.zcml
U CMF/branches/tseaver-viewification/CMFCore/exportimport/actions.py
A CMF/branches/tseaver-viewification/CMFCore/exportimport/cachingpolicymgr.py
U CMF/branches/tseaver-viewification/CMFCore/exportimport/configure.zcml
U CMF/branches/tseaver-viewification/CMFCore/exportimport/content.py
A CMF/branches/tseaver-viewification/CMFCore/exportimport/contenttyperegistry.py
A CMF/branches/tseaver-viewification/CMFCore/exportimport/properties.py
U CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_actions.py
A CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_cachingpolicymgr.py
U CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_content.py
A CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_contenttyperegistry.py
U CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_cookieauth.py
A CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_properties.py
U CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_typeinfo.py
U CMF/branches/tseaver-viewification/CMFCore/fiveactionstool.py
U CMF/branches/tseaver-viewification/CMFCore/interfaces/__init__.py
D CMF/branches/tseaver-viewification/CMFCore/interfaces/_exportimport.py
U CMF/branches/tseaver-viewification/CMFCore/interfaces/_tools.py
U CMF/branches/tseaver-viewification/CMFCore/tests/base/testcase.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_ActionsTool.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_CachingPolicyManager.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_CatalogTool.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_OpaqueItems.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalContent.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalFolder.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_SkinsTool.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_TypesTool.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_WorkflowTool.py
D CMF/branches/tseaver-viewification/CMFCore/tests/test_all.py
U CMF/branches/tseaver-viewification/CMFCore/tests/test_fiveactionstool.py
U CMF/branches/tseaver-viewification/CMFCore/utils.py
U CMF/branches/tseaver-viewification/CMFDefault/DEPENDENCIES.txt
U CMF/branches/tseaver-viewification/CMFDefault/DefaultWorkflow.py
U CMF/branches/tseaver-viewification/CMFDefault/DiscussionItem.py
U CMF/branches/tseaver-viewification/CMFDefault/Document.py
U CMF/branches/tseaver-viewification/CMFDefault/Favorite.py
U CMF/branches/tseaver-viewification/CMFDefault/File.py
U CMF/branches/tseaver-viewification/CMFDefault/Image.py
U CMF/branches/tseaver-viewification/CMFDefault/Link.py
U CMF/branches/tseaver-viewification/CMFDefault/NewsItem.py
U CMF/branches/tseaver-viewification/CMFDefault/Portal.py
U CMF/branches/tseaver-viewification/CMFDefault/SkinnedFolder.py
U CMF/branches/tseaver-viewification/CMFDefault/__init__.py
U CMF/branches/tseaver-viewification/CMFDefault/configure.zcml
D CMF/branches/tseaver-viewification/CMFDefault/exportimport.zcml
U CMF/branches/tseaver-viewification/CMFDefault/profiles/default/cachingpolicymgr.xml
U CMF/branches/tseaver-viewification/CMFDefault/profiles/default/contenttyperegistry.xml
U CMF/branches/tseaver-viewification/CMFDefault/profiles/default/properties.xml
U CMF/branches/tseaver-viewification/CMFDefault/setuphandlers.py
A CMF/branches/tseaver-viewification/CMFDefault/tests/common.py
U CMF/branches/tseaver-viewification/CMFDefault/tests/test_DiscussionReply.py
U CMF/branches/tseaver-viewification/CMFDefault/tests/test_Document.py
U CMF/branches/tseaver-viewification/CMFDefault/tests/test_Favorite.py
A CMF/branches/tseaver-viewification/CMFDefault/tests/test_File.py
U CMF/branches/tseaver-viewification/CMFDefault/tests/test_Image.py
U CMF/branches/tseaver-viewification/CMFDefault/tests/test_Link.py
U CMF/branches/tseaver-viewification/CMFDefault/tests/test_NewsItem.py
U CMF/branches/tseaver-viewification/CMFDefault/tests/test_Portal.py
D CMF/branches/tseaver-viewification/CMFDefault/tests/test_all.py
U CMF/branches/tseaver-viewification/CMFDefault/utils.py
A CMF/branches/tseaver-viewification/CMFSetup/Extensions/
U CMF/branches/tseaver-viewification/CMFSetup/cachingpolicymgr.py
U CMF/branches/tseaver-viewification/CMFSetup/contenttyperegistry.py
U CMF/branches/tseaver-viewification/CMFSetup/properties.py
D CMF/branches/tseaver-viewification/CMFSetup/tests/common.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_actions.py
D CMF/branches/tseaver-viewification/CMFSetup/tests/test_all.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_cachingpolicymgr.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_catalog.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_contenttyperegistry.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_cookieauth.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_mailhost.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_properties.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_skins.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_typeinfo.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_utils.py
U CMF/branches/tseaver-viewification/CMFSetup/tests/test_workflow.py
U CMF/branches/tseaver-viewification/CMFSetup/utils.py
U CMF/branches/tseaver-viewification/CMFSetup/workflow.py
D CMF/branches/tseaver-viewification/CMFSetup/xml/cpmExport.xml
D CMF/branches/tseaver-viewification/CMFSetup/xml/ctrExport.xml
D CMF/branches/tseaver-viewification/CMFSetup/xml/spcExport.xml
U CMF/branches/tseaver-viewification/CMFSetup/xml/wtcWorkflowExport.xml
D CMF/branches/tseaver-viewification/CMFTopic/Extensions/
D CMF/branches/tseaver-viewification/CMFTopic/README.txt
U CMF/branches/tseaver-viewification/CMFTopic/Topic.py
U CMF/branches/tseaver-viewification/CMFTopic/__init__.py
U CMF/branches/tseaver-viewification/CMFTopic/tests/test_DateC.py
U CMF/branches/tseaver-viewification/CMFTopic/tests/test_Topic.py
D CMF/branches/tseaver-viewification/CMFTopic/tests/test_all.py
D CMF/branches/tseaver-viewification/CMFUid/tests/test_all.py
U CMF/branches/tseaver-viewification/CMFUid/tests/test_uidhandling.py
D CMF/branches/tseaver-viewification/DCWorkflow/tests/test_all.py
U CMF/branches/tseaver-viewification/GenericSetup/CHANGES.txt
U CMF/branches/tseaver-viewification/GenericSetup/MailHost/exportimport.py
U CMF/branches/tseaver-viewification/GenericSetup/MailHost/tests/test_exportimport.py
U CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/exportimport.py
U CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/tests/test_exportimport.py
U CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/exportimport.py
U CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/tests/test_exportimport.py
U CMF/branches/tseaver-viewification/GenericSetup/ZCatalog/tests/test_exportimport.py
U CMF/branches/tseaver-viewification/GenericSetup/configure.zcml
A CMF/branches/tseaver-viewification/GenericSetup/content.py
U CMF/branches/tseaver-viewification/GenericSetup/context.py
U CMF/branches/tseaver-viewification/GenericSetup/interfaces.py
U CMF/branches/tseaver-viewification/GenericSetup/rolemap.py
U CMF/branches/tseaver-viewification/GenericSetup/testing.py
U CMF/branches/tseaver-viewification/GenericSetup/tests/common.py
U CMF/branches/tseaver-viewification/GenericSetup/tests/conformance.py
A CMF/branches/tseaver-viewification/GenericSetup/tests/faux_objects.py
A CMF/branches/tseaver-viewification/GenericSetup/tests/test_content.py
U CMF/branches/tseaver-viewification/GenericSetup/tests/test_context.py
U CMF/branches/tseaver-viewification/GenericSetup/tests/test_tool.py
U CMF/branches/tseaver-viewification/GenericSetup/tests/test_utils.py
U CMF/branches/tseaver-viewification/GenericSetup/tool.py
U CMF/branches/tseaver-viewification/GenericSetup/utils.py
U CMF/branches/tseaver-viewification/GenericSetup/version.txt
U CMF/branches/tseaver-viewification/GenericSetup/www/sutImportSteps.zpt
D CMF/branches/tseaver-viewification/GenericSetup/xml/spcExport.xml
D CMF/branches/tseaver-viewification/all_cmf_tests.py
-=-
Modified: CMF/branches/tseaver-viewification/CHANGES.txt
===================================================================
--- CMF/branches/tseaver-viewification/CHANGES.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CHANGES.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -4,6 +4,7 @@
- CMFDefault and CMFTopic: Split off CMFTopic profile.
CMFTopic support is now configured by an optional extension profile.
+ CMFDefault no longer depends on CMFTopic.
- TypesTool: Improved add form for type info objects.
Presettings can now be loaded from type info settings in setup profiles.
@@ -93,6 +94,15 @@
Bug Fixes
+ - CMFSetup: fixed empty attribute parsing when an encoding is
+ defined.
+
+ - ActionProviderBase: getActionObject did stumble over newstyle Actions.
+
+ - CMFCore.exportimport.content: Ensure that BODYFILE in our "faux"
+ request is a file-like object, FBO objects which expect to call its
+ 'read' method.
+
- Got rid of the "CMF Site" and "Configured CMF Site" duality in the ZMI
add list by removing the "CMF Site" class registration in CMFDefault
and moving the "Configured CMF Site" registration from CMFSetup into
@@ -130,6 +140,24 @@
Others
+ - Workflow: Removed deprecated WorkflowInformation and getActionsFor.
+
+ - CMFCore and GenericSetup: Moved mechanisms for content export / import
+ to GenericSetup/content.py, and made more generic.
+
+ - CMFDefault: Removed PortalGenerator and manage_addCMFSite.
+
+ - Portal Types: Removed factory_type_information data.
+ TypesTool.listDefaultTypeInformation was removed, the 'fti' argument of
+ utils.ContentInit and the 'typeinfo_name' argument of
+ TypesTool.manage_addTypeInformation are ignored.
+
+ - CatalogTool: A new portal_catalog is now empty.
+ Removed enumerateIndexes, enumerateLexicons, enumerateColumns and
+ _initIndexes. Please use the setup tool to populate the catalog.
+
+ - CMFActionIcons, CMFCalendar and CMFTopic: Removed old install scripts.
+
- Refactored and extended CMFDefault.tests.test_join so it can be easily
subclassed and reused for alternative membership implementations. All
that is needed is to ovverride _createPortal to return a portal with
Modified: CMF/branches/tseaver-viewification/CMFActionIcons/DEPENDENCIES.txt
===================================================================
--- CMF/branches/tseaver-viewification/CMFActionIcons/DEPENDENCIES.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFActionIcons/DEPENDENCIES.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,3 +1,4 @@
Zope >= 2.8.2
Five >= 1.2
CMFCore
+GenericSetup
Deleted: CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,36 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFActionIcons tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite('Products.CMFActionIcons.tests',[
- 'test_ActionIconsTool',
- ])
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
Modified: CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFActionIcons/tests/test_exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -14,15 +14,15 @@
$Id$
"""
+
import unittest
-#import Testing
+import Testing
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-from Products.CMFSetup.tests.common import BaseRegistryTests
-from Products.CMFSetup.tests.common import DummyExportContext
-from Products.CMFSetup.tests.common import DummyImportContext
-
class _ActionIconsToolSetup(BaseRegistryTests):
CATEGORY = 'testing'
Modified: CMF/branches/tseaver-viewification/CMFCalendar/Event.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCalendar/Event.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCalendar/Event.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -36,28 +36,6 @@
from permissions import ModifyPortalContent
from permissions import View
-# Factory type information -- makes Events objects play nicely
-# with the Types Tool (portal_types)
-factory_type_information = (
- {'id': 'Event',
- 'icon': 'event_icon.gif',
- 'meta_type': 'CMF Event',
- 'description': ('Events are objects for use in Calendar topical '
- 'queries on the catalog.'),
- 'product': 'CMFCalendar',
- 'factory': 'addEvent',
- 'immediate_view': 'event_edit_form',
- 'actions': ({'id': 'view',
- 'name': 'View',
- 'action': 'string:${object_url}/event_view',
- 'permissions': (View,)},
- {'id': 'edit',
- 'name': 'Edit',
- 'action': 'string:${object_url}/event_edit_form',
- 'permissions': (ChangeEvents,)},
- ), # End Actions
- },
- )
def addEvent(self
, id
@@ -73,9 +51,8 @@
, contact_phone=''
, event_url=''
, REQUEST=None):
+ """Create an empty event.
"""
- Create an empty event.
- """
event = Event(id
, title
, description
@@ -106,10 +83,12 @@
return strings
+
class Event(PortalContent, DefaultDublinCoreImpl):
+
+ """Events are objects for the Calendar topical query.
"""
- Events are objects for the Calendar topical query.
- """
+
meta_type='CMF Event'
# Declarative security
@@ -428,5 +407,4 @@
""" Used for FTP and apparently the ZMI now too """
return len(self.manage_FTPget())
-# Intialize the Event class, setting up security.
InitializeClass(Event)
Deleted: CMF/branches/tseaver-viewification/CMFCalendar/INSTALL.txt
===================================================================
--- CMF/branches/tseaver-viewification/CMFCalendar/INSTALL.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCalendar/INSTALL.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,28 +0,0 @@
-Installing CMFCalendar
-
- To install CMFCalendar, uncompress the CMFCalendar product into
- your zope/Products directory or link it there, e.g.::
-
- ln -s /path/to/installation /path/to/zope/Products
-
- In the root of your CMFSite installation (within the ZMI):
-
- 1. Add an external method to the root of the CMF Site.
-
- 2. Use the following configuration values for the external
- method:
-
- o id: install_events
-
- o title: Install Events *optional*
-
- o module name: CMFCalendar.Install
-
- o function name: install
-
- 3. Go to the management screen for the newly added external
- method and click the 'Try it' tab.
-
- The install function will execute and give information about the
- steps it took to register and install the CMF Events into the CMF
- Site instance.
Modified: CMF/branches/tseaver-viewification/CMFCalendar/README.txt
===================================================================
--- CMF/branches/tseaver-viewification/CMFCalendar/README.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCalendar/README.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -17,9 +17,9 @@
now accompanyied by the CMFCalendar which is fully functional
and tested.
+ For installing set the 'active site configuration' of your site's
+ setup tool to the CMFCalendar profile and import all steps.
+
After installing the CMFCalendar you should notice a calendar
appear in your CMF. This is fully customisable to your portals
needs.
-
- See the INSTALL.txt file for how to get the product installed
- within your CMF.
Modified: CMF/branches/tseaver-viewification/CMFCalendar/__init__.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCalendar/__init__.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCalendar/__init__.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -55,7 +55,6 @@
, content_types = contentClasses
, permission = AddPortalContent
, extra_constructors = contentConstructors
- , fti = Event.factory_type_information
).initialize( context )
profile_registry.registerProfile('default',
Deleted: CMF/branches/tseaver-viewification/CMFCalendar/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCalendar/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCalendar/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,37 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFCalendar tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite('Products.CMFCalendar.tests',[
- 'test_Calendar',
- 'test_Event',
- ])
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
Modified: CMF/branches/tseaver-viewification/CMFCalendar/utils.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCalendar/utils.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCalendar/utils.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -16,10 +16,13 @@
"""
from AccessControl import ModuleSecurityInfo
-from zope.i18nmessageid import MessageIDFactory
+try:
+ from zope.i18nmessageid import MessageFactory
+except ImportError: # BBB
+ from zope.i18nmessageid import MessageIDFactory as MessageFactory
security = ModuleSecurityInfo('Products.CMFCalendar.utils')
security.declarePublic('MessageID')
-MessageID = MessageIDFactory('cmf_calendar')
+MessageID = MessageFactory('cmf_calendar')
Modified: CMF/branches/tseaver-viewification/CMFCore/ActionInformation.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/ActionInformation.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/ActionInformation.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -25,7 +25,7 @@
from OFS.OrderedFolder import OrderedFolder
from OFS.SimpleItem import SimpleItem
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from zope.i18nmessageid import MessageID
+
from zope.interface import implements
from Products.GenericSetup.interfaces import INodeImporter
@@ -40,6 +40,7 @@
from utils import _wwwdir
from utils import getToolByName
from utils import SimpleItemWithProperties
+from utils import MessageFactory
_unchanged = [] # marker
@@ -164,7 +165,7 @@
elif id == 'i18n_domain':
continue
elif self.i18n_domain and id in ('title', 'description'):
- val = MessageID(val, self.i18n_domain)
+ val = MessageFactory(self.i18n_domain)(val)
lazy_map[id] = val
return (lazy_map, lazy_keys)
@@ -607,7 +608,7 @@
self.folder_url = self.portal_url
self.folder = portal
- # The name "content" is deprecated and will go away in CMF 1.7!
+ # The name "content" is deprecated and will go away in CMF 2.0!
self.object = self.content = object
if object is not None:
self.content_url = self.object_url = object.absolute_url()
Modified: CMF/branches/tseaver-viewification/CMFCore/ActionProviderBase.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/ActionProviderBase.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/ActionProviderBase.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -72,8 +72,11 @@
# search for action and return first one found
for ai in self.listActions():
- if id == ai.getId() and category == ai.getCategory():
- return ai
+ try:
+ if id == ai.getId() and category == ai.getCategory():
+ return ai
+ except AttributeError:
+ continue
# no action found
return None
Modified: CMF/branches/tseaver-viewification/CMFCore/CMFBTreeFolder.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/CMFBTreeFolder.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/CMFBTreeFolder.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -21,24 +21,8 @@
from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base
from PortalFolder import PortalFolderBase
-from PortalFolder import factory_type_information as PortalFolder_FTI
-_actions = PortalFolder_FTI[0]['actions']
-factory_type_information = ( { 'id' : 'CMF BTree Folder',
- 'meta_type' : 'CMF BTree Folder',
- 'description' : """\
-CMF folder designed to hold a lot of objects.""",
- 'icon' : 'folder_icon.gif',
- 'product' : 'CMFCore',
- 'factory' : 'manage_addCMFBTreeFolder',
- 'filter_content_types' : 0,
- 'immediate_view' : 'folder_edit_form',
- 'actions' : _actions,
- },
- )
-
-
def manage_addCMFBTreeFolder(dispatcher, id, title='', REQUEST=None):
"""Adds a new BTreeFolder object with id *id*.
"""
@@ -52,8 +36,10 @@
class CMFBTreeFolder(BTreeFolder2Base, PortalFolderBase):
+
"""BTree folder for CMF sites.
"""
+
meta_type = 'CMF BTree Folder'
security = ClassSecurityInfo()
@@ -65,5 +51,4 @@
PortalFolderBase._checkId(self, id, allow_dup)
BTreeFolder2Base._checkId(self, id, allow_dup)
-
InitializeClass(CMFBTreeFolder)
Modified: CMF/branches/tseaver-viewification/CMFCore/CachingPolicyManager.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/CachingPolicyManager.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/CachingPolicyManager.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -29,6 +29,7 @@
from permissions import ManagePortal
from permissions import View
from Expression import Expression
+from interfaces import ICachingPolicy
from interfaces import ICachingPolicyManager
from interfaces.CachingPolicyManager \
import CachingPolicyManager as z2ICachingPolicyManager
@@ -50,7 +51,7 @@
if time is None:
time = DateTime()
- # The name "content" is deprecated and will go away in CMF 1.7,
+ # The name "content" is deprecated and will go away in CMF 2.0,
# please use "object" in your policy
data = { 'content' : content
, 'object' : content
@@ -153,6 +154,8 @@
"""
+ implements(ICachingPolicy)
+
def __init__( self
, policy_id
, predicate=''
@@ -430,15 +433,9 @@
security.declarePublic( 'listPolicies' )
def listPolicies( self ):
+ """List '(id, (policy, typeObjectName))' tuples for all policies.
"""
- Return a sequence of tuples,
- '( policy_id, ( policy, typeObjectName ) )'
- for all policies in the registry
- """
- result = []
- for policy_id in self._policy_ids:
- result.append( ( policy_id, self._policies[ policy_id ] ) )
- return tuple( result )
+ return tuple([ (id, self._policies[id]) for id in self._policy_ids ])
security.declareProtected( ManagePortal, 'addPolicy' )
def addPolicy( self
Modified: CMF/branches/tseaver-viewification/CMFCore/CatalogTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/CatalogTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/CatalogTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -21,11 +21,6 @@
from Globals import DTMLFile
from Globals import InitializeClass
from Products.ZCatalog.ZCatalog import ZCatalog
-from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
-from Products.ZCTextIndex.Lexicon import CaseNormalizer
-from Products.ZCTextIndex.Lexicon import Splitter
-from Products.ZCTextIndex.Lexicon import StopWordRemover
-from Products.ZCTextIndex.ZCTextIndex import PLexicon
from zope.interface import implements
from ActionProviderBase import ActionProviderBase
@@ -42,7 +37,6 @@
from utils import _getAuthenticatedUser
from utils import _mergedLocalRoles
from utils import getToolByName
-from utils import SimpleRecord
from utils import UniqueObject
@@ -102,97 +96,8 @@
def __init__(self):
ZCatalog.__init__(self, self.getId())
- self._initIndexes()
#
- # Subclass extension interface
- #
- security.declarePublic('enumerateIndexes') # Subclass can call
- def enumerateIndexes(self):
- # Return a list of ( index_name, type, extra ) tuples for the initial
- # index set.
- plaintext_extra = SimpleRecord( lexicon_id='plaintext_lexicon'
- , index_type='Okapi BM25 Rank'
- )
- htmltext_extra = SimpleRecord( lexicon_id='htmltext_lexicon'
- , index_type='Okapi BM25 Rank'
- )
-
- return ( ('Title', 'ZCTextIndex', plaintext_extra)
- , ('Subject', 'KeywordIndex', None)
- , ('Description', 'ZCTextIndex', plaintext_extra)
- , ('listCreators', 'KeywordIndex', None)
- , ('SearchableText', 'ZCTextIndex', htmltext_extra)
- , ('Date', 'DateIndex', None)
- , ('Type', 'FieldIndex', None)
- , ('created', 'DateIndex', None)
- , ('effective', 'DateIndex', None)
- , ('expires', 'DateIndex', None)
- , ('modified', 'DateIndex', None)
- , ('allowedRolesAndUsers', 'KeywordIndex', None)
- , ('review_state', 'FieldIndex', None)
- , ('in_reply_to', 'FieldIndex', None)
- , ('getId', 'FieldIndex', None)
- , ('path', 'PathIndex', None)
- , ('portal_type', 'FieldIndex', None)
- )
-
- security.declarePublic('enumerateLexicons')
- def enumerateLexicons(self):
- return (
- ( 'plaintext_lexicon'
- , Splitter()
- , CaseNormalizer()
- , StopWordRemover()
- )
- , ( 'htmltext_lexicon'
- , HTMLWordSplitter()
- , CaseNormalizer()
- , StopWordRemover()
- )
- )
-
- security.declarePublic('enumerateColumns')
- def enumerateColumns(self):
- # Return a sequence of schema names to be cached.
- return ( 'Subject'
- , 'Title'
- , 'Description'
- , 'Type'
- , 'review_state'
- , 'listCreators'
- , 'Date'
- , 'getIcon'
- , 'created'
- , 'effective'
- , 'expires'
- , 'modified'
- , 'CreationDate'
- , 'EffectiveDate'
- , 'ExpirationDate'
- , 'ModificationDate'
- , 'getId'
- , 'portal_type'
- )
-
- def _initIndexes(self):
- # ZCTextIndex lexicons
- for id, splitter, normalizer, sw_remover in self.enumerateLexicons():
- lexicon = PLexicon(id, '', splitter, normalizer, sw_remover)
- self._setObject(id, lexicon)
-
- # Content indexes
- self._catalog.indexes.clear()
- for index_name, index_type, extra in self.enumerateIndexes():
- self.addIndex(index_name, index_type, extra=extra)
-
- # Cached metadata
- self._catalog.names = ()
- self._catalog.schema.clear()
- for column_name in self.enumerateColumns():
- self.addColumn(column_name)
-
- #
# ZMI methods
#
security.declareProtected(ManagePortal, 'manage_overview')
Modified: CMF/branches/tseaver-viewification/CMFCore/ContentTypeRegistry.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/ContentTypeRegistry.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/ContentTypeRegistry.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -457,15 +457,10 @@
security.declarePublic( 'listPredicates' )
def listPredicates( self ):
+ """List '(id, (predicate, typeObjectName))' tuples for all predicates.
"""
- Return a sequence of tuples,
- '( id, ( predicate, typeObjectName ) )'
- for all predicates in the registry
- """
- result = []
- for predicate_id in self.predicate_ids:
- result.append( ( predicate_id, self.predicates[ predicate_id ] ) )
- return tuple( result )
+ return tuple([ (id, self.predicates[id])
+ for id in self.predicate_ids ])
security.declarePublic( 'getTypeObjectName' )
def getTypeObjectName( self, predicate_id ):
Modified: CMF/branches/tseaver-viewification/CMFCore/FSMetadata.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/FSMetadata.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/FSMetadata.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -159,7 +159,7 @@
except IOError:
return None
else:
- warn('.properties objects will disappear in CMF 1.7 - Use '
+ warn('.properties objects will disappear in CMF 2.0 - Use '
'.metadata objects instead.', DeprecationWarning)
lines = f.readlines()
f.close()
@@ -189,7 +189,7 @@
except IOError:
return None
else:
- warn('.security objects will disappear in CMF 1.7 - Use '
+ warn('.security objects will disappear in CMF 2.0 - Use '
'.metadata objects instead.', DeprecationWarning)
lines = f.readlines()
f.close()
Modified: CMF/branches/tseaver-viewification/CMFCore/PortalFolder.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/PortalFolder.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/PortalFolder.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -37,7 +37,6 @@
from interfaces.Folderish import Folderish as z2IFolderish
from permissions import AddPortalContent
from permissions import AddPortalFolders
-from permissions import ChangeLocalRoles
from permissions import DeleteObjects
from permissions import ListFolderContents
from permissions import ManagePortal
@@ -47,61 +46,11 @@
from utils import getToolByName
-factory_type_information = (
- { 'id' : 'Folder'
- , 'meta_type' : 'Portal Folder'
- , 'description' : """ Use folders to put content in categories."""
- , 'icon' : 'folder_icon.gif'
- , 'product' : 'CMFCore'
- , 'factory' : 'manage_addPortalFolder'
- , 'filter_content_types' : 0
- , 'immediate_view' : 'folder_edit_form'
- , 'aliases' : {'(Default)': 'index_html',
- 'view': 'index_html',
- 'index.html':'index_html'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/folder_edit_form'
- , 'permissions' : (ManageProperties,)
- }
- , { 'id' : 'localroles'
- , 'name' : 'Local Roles'
- , 'action':
- 'string:${object_url}/folder_localrole_form'
- , 'permissions' : (ChangeLocalRoles,)
- }
- , { 'id' : 'folderContents'
- , 'name' : 'Folder contents'
- , 'action': 'string:${object_url}/folder_contents'
- , 'permissions' : (ListFolderContents,)
- }
- , { 'id' : 'new'
- , 'name' : 'New...'
- , 'action': 'string:${object_url}/folder_factories'
- , 'permissions' : (AddPortalContent,)
- , 'visible' : 0
- }
- , { 'id' : 'rename_items'
- , 'name' : 'Rename items'
- , 'action': 'string:${object_url}/folder_rename_form'
- , 'permissions' : (AddPortalContent,)
- , 'visible' : 0
- }
- )
- }
-,
-)
-
-
class PortalFolderBase(DynamicType, CMFCatalogAware, Folder):
"""Base class for portal folder
"""
+
meta_type = 'Portal Folder Base'
implements(IFolderish)
Modified: CMF/branches/tseaver-viewification/CMFCore/PortalObject.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/PortalObject.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/PortalObject.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -16,21 +16,24 @@
"""
from Globals import InitializeClass
+from zope.interface import implements
-from PortalFolder import PortalFolder
-from Skinnable import SkinnableObjectManager
+from interfaces import ISiteRoot
from permissions import AddPortalMember
from permissions import SetOwnPassword
from permissions import SetOwnProperties
from permissions import MailForgottenPassword
from permissions import RequestReview
from permissions import ReviewPortalContent
+from PortalFolder import PortalFolder
+from Skinnable import SkinnableObjectManager
PORTAL_SKINS_TOOL_ID = 'portal_skins'
class PortalObjectBase(PortalFolder, SkinnableObjectManager):
+ implements(ISiteRoot)
meta_type = 'Portal Site'
_isPortalRoot = 1
Modified: CMF/branches/tseaver-viewification/CMFCore/Skinnable.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/Skinnable.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/Skinnable.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -40,7 +40,7 @@
_marker = [] # Create a new marker object.
-SKINDATA = {} # mapping thread-id -> (skinobj, ignore, resolve)
+SKINDATA = {} # mapping thread-id -> (skinobj, skinname, ignore, resolve)
class SkinDataCleanup:
"""Cleanup at the end of the request."""
@@ -71,7 +71,7 @@
if not name.startswith('_') and not name.startswith('aq_'):
sd = SKINDATA.get(get_ident())
if sd is not None:
- ob, ignore, resolve = sd
+ ob, skinname, ignore, resolve = sd
if not ignore.has_key(name):
if resolve.has_key(name):
return resolve[name]
@@ -126,11 +126,29 @@
skinobj = self.getSkin(skinname)
if skinobj is not None:
tid = get_ident()
- SKINDATA[tid] = (skinobj, {}, {})
+ SKINDATA[tid] = (skinobj, skinname, {}, {})
REQUEST = getattr(self, 'REQUEST', None)
if REQUEST is not None:
REQUEST._hold(SkinDataCleanup(tid))
+ security.declarePublic('getCurrentSkinName')
+ def getCurrentSkinName(self):
+ '''Return the current skin name.
+ '''
+ sd = SKINDATA.get(get_ident())
+ if sd is not None:
+ ob, skinname, ignore, resolve = sd
+ if skinname is not None:
+ return skinname
+ # nothing here, so assume the default skin
+ sfn = self.getSkinsFolderName()
+ if sfn is not None:
+ sf = getattr(self, sfn, None)
+ if sf is not None:
+ return sf.getDefaultSkin()
+ # and if that fails...
+ return None
+
security.declarePublic('clearCurrentSkin')
def clearCurrentSkin(self):
"""Clear the current skin."""
Modified: CMF/branches/tseaver-viewification/CMFCore/TypesTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/TypesTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/TypesTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -30,9 +30,15 @@
from OFS.ObjectManager import IFAwareObjectManager
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from zLOG import LOG, ERROR
-from zope.i18nmessageid import MessageID
from zope.interface import implements
+try:
+ from zope.i18nmessageid import MessageFactory
+except ImportError: # BBB
+ from zope.i18nmessageid import MessageIDFactory as MessageFactory
+def MessageID(val, domain): # XXX performance?
+ return MessageFactory(domain)(val)
+
from Products.GenericSetup.interfaces import INodeImporter
from ActionProviderBase import ActionProviderBase
@@ -244,11 +250,6 @@
if contentType in self.allowed_content_types:
return 1
- # Backward compatibility for code that expected Type() to work.
- for ti in self.listTypeInfo():
- if ti.Title() == contentType:
- return ti.getId() in self.allowed_content_types
-
return 0
security.declarePublic('getId')
@@ -754,76 +755,12 @@
#
# other methods
#
- security.declareProtected(ManagePortal, 'listDefaultTypeInformation')
- def listDefaultTypeInformation(self):
- # Scans for factory_type_information attributes
- # of all products and factory dispatchers within products.
- res = []
- products = self.aq_acquire('_getProducts')()
- for product in products.objectValues():
- product_id = product.getId()
-
- if hasattr(aq_base(product), 'factory_type_information'):
- ftis = product.factory_type_information
- else:
- package = getattr(Products, product_id, None)
- dispatcher = getattr(package, '__FactoryDispatcher__', None)
- ftis = getattr(dispatcher, 'factory_type_information', None)
-
- if ftis is not None:
- if callable(ftis):
- ftis = ftis()
-
- for fti in ftis:
- mt = fti.get('meta_type', None)
- id = fti.get('id', '')
-
- if mt:
- p_id = '%s: %s (%s)' % (product_id, id, mt)
- res.append( (p_id, fti) )
-
- return res
-
security.declareProtected(ManagePortal, 'manage_addTypeInformation')
def manage_addTypeInformation(self, add_meta_type, id=None,
typeinfo_name=None, RESPONSE=None):
+ """Create a TypeInformation in self.
"""
- Create a TypeInformation in self.
- """
- fti = None
- if typeinfo_name:
- info = self.listDefaultTypeInformation()
-
- # Nasty orkaround to stay backwards-compatible
- # This workaround will disappear in CMF 1.7
- if typeinfo_name.endswith(')'):
- # This is a new-style name. Proceed normally.
- for (name, ft) in info:
- if name == typeinfo_name:
- fti = ft
- break
- else:
- # Attempt to work around the old way
- # This attempt harbors the problem that the first match on
- # meta_type will be used. There could potentially be more
- # than one TypeInformation sharing the same meta_type.
- warn('Please switch to the new format for typeinfo names '
- '\"product_id: type_id (meta_type)\", the old '
- 'spelling will disappear in CMF 1.7', DeprecationWarning,
- stacklevel=2)
-
- ti_prod, ti_mt = [x.strip() for x in typeinfo_name.split(':')]
-
- for name, ft in info:
- if ( name.startswith(ti_prod) and
- name.endswith('(%s)' % ti_mt) ):
- fti = ft
- break
-
- if fti is None:
- raise BadRequest('%s not found.' % typeinfo_name)
- if not id:
- id = fti.get('id', None)
+ # BBB: typeinfo_name is ignored
if not id:
raise BadRequest('An id is required.')
for mt in Products.meta_types:
@@ -834,13 +771,7 @@
raise ValueError, (
'Meta type %s is not a type class.' % add_meta_type)
id = str(id)
- if fti is not None:
- fti = fti.copy()
- if fti.has_key('id'):
- del fti['id']
- ob = klass(id, **fti)
- else:
- ob = klass(id)
+ ob = klass(id)
self._setObject(id, ob)
if RESPONSE is not None:
RESPONSE.redirect('%s/manage_main' % self.absolute_url())
Modified: CMF/branches/tseaver-viewification/CMFCore/WorkflowTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/WorkflowTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/WorkflowTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -16,7 +16,6 @@
"""
import sys
-from warnings import warn
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base, aq_inner, aq_parent
@@ -40,27 +39,7 @@
_marker = [] # Create a new marker object.
-class WorkflowInformation:
- """ Shim implementation of ActionInformation, to enable
- querying actions without mediation of the 'portal_actions' tool.
- """
- def __init__(self, object):
- warn('WorkflowInformation() is deprecated and will be removed in '
- 'CMF 1.7.',
- DeprecationWarning)
- self.object = self.content = object
- self.content_url = object.absolute_url()
- self.portal_url = self.folder_url = ''
-
- def __getitem__(self, name):
- if name[:1] == '_':
- raise KeyError, name
- if hasattr(self, name):
- return getattr(self, name)
- raise KeyError, name
-
-
class WorkflowTool(UniqueObject, Folder, ActionProviderBase):
""" Mediator tool, mapping workflow objects
@@ -262,17 +241,6 @@
actions.extend(a)
return actions
- security.declarePublic('getActionsFor')
- def getActionsFor(self, ob):
-
- """ Return a list of action dictionaries for 'ob', just as though
- queried via 'ActionsTool.listFilteredActionsFor'.
- """
- warn('getActionsFor() is deprecated and will be removed in CMF 1.7. '
- 'Please use listActionInfos() instead.',
- DeprecationWarning)
- return self.listActions( WorkflowInformation( ob ) )
-
security.declarePublic('doActionFor')
def doActionFor(self, ob, action, wf_id=None, *args, **kw):
Modified: CMF/branches/tseaver-viewification/CMFCore/__init__.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/__init__.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/__init__.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -81,11 +81,7 @@
, CMFBTreeFolder.manage_addCMFBTreeFolder
)
-_FTI = ( PortalFolder.factory_type_information
- + CMFBTreeFolder.factory_type_information
- )
-
# Because persistent objects may be out there which were
# created when the module was in that product, we need
# __module_aliases__ .
@@ -189,7 +185,6 @@
, content_types=_CONTENT_TYPES
, permission=AddPortalFolders
, extra_constructors=_EXTRA_CONSTRUCTORS
- , fti=_FTI
).initialize( context )
# make registerHelp work with 2 directories
Modified: CMF/branches/tseaver-viewification/CMFCore/browser/meta.zcml
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/browser/meta.zcml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/browser/meta.zcml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -2,6 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
+ <!-- Commenting out pending Lennart's fixes for Zope 3.2 compatibility.
<meta:directives namespace="http://namespaces.zope.org/cmf">
<meta:directive
@@ -30,5 +31,6 @@
</meta:complexDirective>
</meta:directives>
+ -->
</configure>
Modified: CMF/branches/tseaver-viewification/CMFCore/exportimport/actions.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/exportimport/actions.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/exportimport/actions.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -23,9 +23,10 @@
from Products.CMFCore.interfaces import IAction
from Products.CMFCore.interfaces import IActionCategory
+from Products.CMFCore.interfaces import IActionProvider
from Products.CMFCore.interfaces import IActionsTool
from Products.CMFCore.interfaces.portal_actions \
- import ActionProvider as IActionProvider
+ import ActionProvider as z2IActionProvider
from Products.CMFCore.utils import getToolByName
_SPECIAL_PROVIDERS = ('portal_actions', 'portal_types', 'portal_workflow')
@@ -77,6 +78,9 @@
def importNode(self, node, mode=PURGE):
"""Import the object from the DOM node.
"""
+ if mode == PURGE:
+ self._purgeProperties()
+
self._initProperties(node, mode)
@@ -123,7 +127,8 @@
fragment = self._doc.createDocumentFragment()
provider = getToolByName(self.context, provider_id)
- if not IActionProvider.isImplementedBy(provider):
+ if not (IActionProvider.providedBy(provider) or
+ z2IActionProvider.isImplementedBy(provider)):
return fragment
if provider_id == 'portal_actions':
Copied: CMF/branches/tseaver-viewification/CMFCore/exportimport/cachingpolicymgr.py (from rev 40248, CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py)
Modified: CMF/branches/tseaver-viewification/CMFCore/exportimport/configure.zcml
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/exportimport/configure.zcml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/exportimport/configure.zcml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -41,51 +41,51 @@
/>
<adapter
- factory=".content.StructureFolderWalkingAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemExporter"
- for="Products.CMFCore.interfaces.IFolderish"
+ factory=".cachingpolicymgr.CachingPolicyNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.ICachingPolicy"
/>
<adapter
- factory=".content.StructureFolderWalkingAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemImporter"
- for="Products.CMFCore.interfaces.IFolderish"
+ factory=".cachingpolicymgr.CachingPolicyNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.ICachingPolicy"
/>
<adapter
- factory=".content.CSVAwareFileAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemExporter"
- for="Products.CMFCore.interfaces.ICSVAware"
+ factory=".cachingpolicymgr.CachingPolicyManagerNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.ICachingPolicyManager"
/>
<adapter
- factory=".content.CSVAwareFileAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemImporter"
- for="Products.CMFCore.interfaces.ICSVAware"
+ factory=".cachingpolicymgr.CachingPolicyManagerNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.ICachingPolicyManager"
/>
<adapter
- factory=".content.INIAwareFileAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemExporter"
- for="Products.CMFCore.interfaces.IINIAware"
+ factory=".content.StructureFolderWalkingAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemExporter"
+ for="Products.CMFCore.interfaces.IFolderish"
/>
<adapter
- factory=".content.INIAwareFileAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemImporter"
- for="Products.CMFCore.interfaces.IINIAware"
+ factory=".content.StructureFolderWalkingAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemImporter"
+ for="Products.CMFCore.interfaces.IFolderish"
/>
<adapter
- factory=".content.DAVAwareFileAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemExporter"
- for="Products.CMFCore.interfaces.IDAVAware"
+ factory=".contenttyperegistry.ContentTypeRegistryNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.IContentTypeRegistry"
/>
<adapter
- factory=".content.DAVAwareFileAdapter"
- provides="Products.CMFCore.interfaces.IFilesystemImporter"
- for="Products.CMFCore.interfaces.IDAVAware"
+ factory=".contenttyperegistry.ContentTypeRegistryNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.IContentTypeRegistry"
/>
<adapter
@@ -101,6 +101,18 @@
/>
<adapter
+ factory=".properties.PropertiesNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.ISiteRoot"
+ />
+
+ <adapter
+ factory=".properties.PropertiesNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.ISiteRoot"
+ />
+
+ <adapter
factory=".typeinfo.TypeInformationNodeAdapter"
provides="Products.GenericSetup.interfaces.INodeExporter"
for="Products.CMFCore.interfaces.ITypeInformation"
Modified: CMF/branches/tseaver-viewification/CMFCore/exportimport/content.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/exportimport/content.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/exportimport/content.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -25,19 +25,19 @@
from zope.interface import implements
from zope.interface import directlyProvides
-from Products.CMFCore.interfaces import IFilesystemExporter
-from Products.CMFCore.interfaces import IFilesystemImporter
-from Products.CMFCore.interfaces import ISiteRoot
+from Products.GenericSetup.interfaces import IFilesystemExporter
+from Products.GenericSetup.interfaces import IFilesystemImporter
+from Products.GenericSetup.content import _globtest
from Products.CMFCore.utils import getToolByName
#
# setup_tool handlers
#
def exportSiteStructure(context):
- IFilesystemExporter(context.getSite()).export(context, 'structure')
+ IFilesystemExporter(context.getSite()).export(context, 'structure', True)
def importSiteStructure(context):
- IFilesystemImporter(context.getSite()).import_(context, 'structure')
+ IFilesystemImporter(context.getSite()).import_(context, 'structure', True)
#
@@ -65,7 +65,7 @@
def __init__(self, context):
self.context = context
- def export(self, export_context, subdir):
+ def export(self, export_context, subdir, root=False):
""" See IFilesystemExporter.
"""
# Enumerate exportable children
@@ -79,7 +79,7 @@
for object_id, object, ignored in exportable:
csv_writer.writerow((object_id, object.getPortalTypeName()))
- if not ISiteRoot.providedBy(self.context):
+ if not root:
subdir = '%s/%s' % (subdir, self.context.getId())
export_context.writeDataFile('.objects',
@@ -108,11 +108,11 @@
if adapter is not None:
adapter.export(export_context, subdir)
- def import_(self, import_context, subdir):
+ def import_(self, import_context, subdir, root=False):
""" See IFilesystemImporter.
"""
context = self.context
- if not ISiteRoot.providedBy(context):
+ if not root:
subdir = '%s/%s' % (subdir, context.getId())
preserve = import_context.readDataFile('.preserve', subdir)
@@ -145,9 +145,9 @@
object = self._makeInstance(object_id, portal_type,
subdir, import_context)
if object is None:
- message = "Couldn't make instance: %s/%s" % (subdir,
- object_id)
- import_context.note('SFWA', message)
+ logger = import_context.getLogger('SFWA')
+ logger.warning("Couldn't make instance: %s/%s" %
+ (subdir, object_id))
continue
wrapped = context._getOb(object_id)
@@ -183,142 +183,3 @@
return content
-
-def _globtest(globpattern, namelist):
- """ Filter names in 'namelist', returning those which match 'globpattern'.
- """
- import re
- pattern = globpattern.replace(".", r"\.") # mask dots
- pattern = pattern.replace("*", r".*") # change glob sequence
- pattern = pattern.replace("?", r".") # change glob char
- pattern = '|'.join(pattern.split()) # 'or' each line
-
- compiled = re.compile(pattern)
-
- return filter(compiled.match, namelist)
-
-
-class CSVAwareFileAdapter(object):
- """ Adapter for content whose "natural" representation is CSV.
- """
- implements(IFilesystemExporter, IFilesystemImporter)
-
- def __init__(self, context):
- self.context = context
-
- def export(self, export_context, subdir):
- """ See IFilesystemExporter.
- """
- export_context.writeDataFile('%s.csv' % self.context.getId(),
- self.context.as_csv(),
- 'text/comma-separated-values',
- subdir,
- )
-
- def listExportableItems(self):
- """ See IFilesystemExporter.
- """
- return ()
-
- def import_(self, import_context, subdir):
- """ See IFilesystemImporter.
- """
- cid = self.context.getId()
- data = import_context.readDataFile('%s.csv' % cid, subdir)
- if data is None:
- import_context.note('CSAFA',
- 'no .csv file for %s/%s' % (subdir, cid))
- else:
- stream = StringIO(data)
- self.context.put_csv(stream)
-
-class INIAwareFileAdapter(object):
- """ Exporter/importer for content whose "natural" representation is CSV.
- """
- implements(IFilesystemExporter, IFilesystemImporter)
-
- def __init__(self, context):
- self.context = context
-
- def export(self, export_context, subdir):
- """ See IFilesystemExporter.
- """
- export_context.writeDataFile('%s.ini' % self.context.getId(),
- self.context.as_ini(),
- 'text/plain',
- subdir,
- )
-
- def listExportableItems(self):
- """ See IFilesystemExporter.
- """
- return ()
-
- def import_(self, import_context, subdir):
- """ See IFilesystemImporter.
- """
- cid = self.context.getId()
- data = import_context.readDataFile('%s.ini' % cid, subdir)
- if data is None:
- import_context.note('SGAIFA',
- 'no .ini file for %s/%s' % (subdir, cid))
- else:
- self.context.put_ini(data)
-
-
-class FauxDAVRequest:
-
- def __init__(self, **kw):
- self._data = {}
- self._headers = {}
- self._data.update(kw)
-
- def __getitem__(self, key):
- return self._data[key]
-
- def get(self, key, default=None):
- return self._data.get(key, default)
-
- def get_header(self, key, default=None):
- return self._headers.get(key, default)
-
-class FauxDAVResponse:
- def setHeader(self, key, value, lock=False):
- pass # stub this out to mollify webdav.Resource
- def setStatus(self, value, reason=None):
- pass # stub this out to mollify webdav.Resource
-
-class DAVAwareFileAdapter(object):
- """ Exporter/importer for content who handle their own FTP / DAV PUTs.
- """
- implements(IFilesystemExporter, IFilesystemImporter)
-
- def __init__(self, context):
- self.context = context
-
- def export(self, export_context, subdir):
- """ See IFilesystemExporter.
- """
- export_context.writeDataFile('%s' % self.context.getId(),
- self.context.manage_FTPget(),
- 'text/plain',
- subdir,
- )
-
- def listExportableItems(self):
- """ See IFilesystemExporter.
- """
- return ()
-
- def import_(self, import_context, subdir):
- """ See IFilesystemImporter.
- """
- cid = self.context.getId()
- data = import_context.readDataFile('%s' % cid, subdir)
- if data is None:
- import_context.note('SGAIFA',
- 'no .ini file for %s/%s' % (subdir, cid))
- else:
- request = FauxDAVRequest(BODY=data, BODYFILE=data)
- response = FauxDAVResponse()
- self.context.PUT(request, response)
Copied: CMF/branches/tseaver-viewification/CMFCore/exportimport/contenttyperegistry.py (from rev 40248, CMF/trunk/CMFCore/exportimport/contenttyperegistry.py)
Copied: CMF/branches/tseaver-viewification/CMFCore/exportimport/properties.py (from rev 40248, CMF/trunk/CMFCore/exportimport/properties.py)
Modified: CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_actions.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_actions.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -20,12 +20,8 @@
import Zope2
Zope2.startup()
-import Products.CMFCore.exportimport
-import Products.Five
-from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
-
from Products.CMFCore.tests.base.dummy import DummySite
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.GenericSetup.testing import NodeAdapterTestCase
@@ -88,8 +84,27 @@
obj._setPropValue('url_expr', 'string:${object_url}/foo')
obj._setPropValue('available_expr', 'python:1')
+ def _verifyImport(self, obj):
+ self.assertEqual(type(obj.title), str)
+ self.assertEqual(obj.title, 'Foo')
+ self.assertEqual(type(obj.description), str)
+ self.assertEqual(obj.description, '')
+ self.assertEqual(type(obj.url_expr), str)
+ self.assertEqual(obj.url_expr, 'string:${object_url}/foo')
+ self.assertEqual(type(obj.icon_expr), str)
+ self.assertEqual(obj.icon_expr, '')
+ self.assertEqual(type(obj.available_expr), str)
+ self.assertEqual(obj.available_expr, 'python:1')
+ self.assertEqual(type(obj.permissions), tuple)
+ self.assertEqual(obj.permissions, ())
+ self.assertEqual(type(obj.visible), bool)
+ self.assertEqual(obj.visible, True)
+
def setUp(self):
from Products.CMFCore.ActionInformation import Action
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
PlacelessSetup.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
@@ -112,8 +127,15 @@
obj._setObject('foo_action', Action('foo_action'))
+ def _verifyImport(self, obj):
+ self.assertEqual(type(obj.title), str)
+ self.assertEqual(obj.title, '')
+
def setUp(self):
from Products.CMFCore.ActionInformation import ActionCategory
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
PlacelessSetup.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
@@ -140,8 +162,17 @@
obj.foo_category._setObject('foo_action', Action('foo_action'))
obj.foo_category.foo_action.i18n_domain = 'foo_domain'
+ def _verifyImport(self, obj):
+ self.assertEqual(type(obj.action_providers), tuple)
+ self.assertEqual(obj.action_providers, ('portal_actions',))
+ self.assertEqual(type(obj.action_providers[0]), str)
+ self.assertEqual(obj.action_providers[0], 'portal_actions')
+
def setUp(self):
from Products.CMFCore.ActionsTool import ActionsTool
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
PlacelessSetup.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
Copied: CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_cachingpolicymgr.py (from rev 40248, CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py)
Modified: CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_content.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_content.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_content.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -22,8 +22,7 @@
from ConfigParser import ConfigParser
from StringIO import StringIO
-from zope.app.tests.placelesssetup import PlacelessSetup
-
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
@@ -51,17 +50,17 @@
from zope.app.tests import ztapi
#from OFS.Image import File
- from Products.CMFCore.interfaces import IFilesystemExporter
- from Products.CMFCore.interfaces import IFilesystemImporter
+ from Products.GenericSetup.interfaces import IFilesystemExporter
+ from Products.GenericSetup.interfaces import IFilesystemImporter
+ from Products.GenericSetup.interfaces import ICSVAware
+ from Products.GenericSetup.interfaces import IINIAware
from Products.CMFCore.interfaces import IFolderish
- from Products.CMFCore.interfaces import ICSVAware
- from Products.CMFCore.interfaces import IINIAware
from Products.CMFCore.exportimport.content import \
StructureFolderWalkingAdapter
- from Products.CMFCore.exportimport.content import \
+ from Products.GenericSetup.content import \
CSVAwareFileAdapter
- from Products.CMFCore.exportimport.content import \
+ from Products.GenericSetup.content import \
INIAwareFileAdapter
#from Products.CMFCore.exportimport.content import \
@@ -358,6 +357,8 @@
self.assertEqual(site.objectIds()[0], 'setup_tool')
def test_import_site_with_subfolders(self):
+ from Products.GenericSetup.tests.test_content \
+ import _PROPERTIES_TEMPLATE
self._setUpAdapters()
FOLDER_IDS = ('foo', 'bar', 'baz')
@@ -430,7 +431,7 @@
after = site.objectIds()
self.assertEqual(len(after), 0)
self.assertEqual(len(context._notes), len(ITEM_IDS))
- for component, message in context._notes:
+ for level, component, message in context._notes:
self.assertEqual(component, 'SFWA')
self.failUnless(message.startswith("Couldn't make"))
@@ -519,177 +520,6 @@
self.assertEqual(site.foo.objectIds()[1], 'baz')
-class Test_globpattern(unittest.TestCase):
-
- NAMELIST = ('foo', 'bar', 'baz', 'bam', 'qux', 'quxx', 'quxxx')
-
- def _checkResults(self, globpattern, namelist, expected):
- from Products.CMFCore.exportimport.content import _globtest
- found = _globtest(globpattern, namelist)
- self.assertEqual(len(found), len(expected))
- for found_item, expected_item in zip(found, expected):
- self.assertEqual(found_item, expected_item)
-
- def test_star(self):
- self._checkResults('*', self.NAMELIST, self.NAMELIST)
-
- def test_simple(self):
- self._checkResults('b*', self.NAMELIST,
- [x for x in self.NAMELIST if x.startswith('b')])
-
- def test_multiple(self):
- self._checkResults('b*\n*x', self.NAMELIST,
- [x for x in self.NAMELIST
- if x.startswith('b') or x.endswith('x')])
-
-
-class CSVAwareFileAdapterTests(unittest.TestCase,
- ConformsToIFilesystemExporter,
- ConformsToIFilesystemImporter,
- ):
-
- def _getTargetClass(self):
- from Products.CMFCore.exportimport.content import CSVAwareFileAdapter
- return CSVAwareFileAdapter
-
- def _makeOne(self, context, *args, **kw):
- return self._getTargetClass()(context, *args, **kw)
-
- def _makeCSVAware(self, sheet_id, csv=''):
- class Foo:
- def getId(self):
- return self._id
- def as_csv(self):
- return self.csv
- def put_csv(self, stream):
- self.new_csv = stream.getvalue()
-
- foo = Foo()
- foo._id = sheet_id
- foo.csv = csv
- foo.new_csv = None
-
- return foo
-
-
- def test_export_with_known_CSV(self):
- KNOWN_CSV = """\
-one,two,three
-four,five,six
-"""
- sheet = self._makeCSVAware('config', KNOWN_CSV)
-
- adapter = self._makeOne(sheet)
- context = DummyExportContext(None)
- adapter.export(context, 'subpath/to/sheet')
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'subpath/to/sheet/config.csv')
- self.assertEqual(content_type, 'text/comma-separated-values')
-
- self.assertEqual(text.strip(), KNOWN_CSV.strip())
-
- def test_import_with_known_CSV(self):
- ORIG_CSV = """\
-one,two,three
-four,five,six
-"""
- NEW_CSV = """\
-four,five,six
-one,two,three
-"""
- sheet = self._makeCSVAware('config', ORIG_CSV)
-
- adapter = self._makeOne(sheet)
- context = DummyImportContext(None)
- context._files['subpath/to/sheet/config.csv'] = NEW_CSV
- adapter.import_(context, 'subpath/to/sheet')
-
- self.assertEqual(sheet.new_csv.strip(), NEW_CSV.strip())
-
-
-_PROPERTIES_TEMPLATE = """
-[DEFAULT]
-Title = %s
-Description = This is a test
-"""
-
-class INIAwareFileAdapterTests(unittest.TestCase,
- ConformsToIFilesystemExporter,
- ConformsToIFilesystemImporter,
- ):
-
- def _getTargetClass(self):
- from Products.CMFCore.exportimport.content import INIAwareFileAdapter
- return INIAwareFileAdapter
-
- def _makeOne(self, context, *args, **kw):
- return self._getTargetClass()(context, *args, **kw)
-
- def test_export_ini_file(self):
- ini_file = _makeINIAware('ini_file.html')
- adapter = self._makeOne(ini_file)
- context = DummyExportContext(None)
- adapter.export(context, 'subpath/to')
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'subpath/to/ini_file.html.ini')
- self.assertEqual(content_type, 'text/plain')
-
- self.assertEqual(text.strip(), ini_file.as_ini().strip())
-
- def test_import_ini_file(self):
- ini_file = _makeINIAware('ini_file.html')
- adapter = self._makeOne(ini_file)
- context = DummyImportContext(None)
- context._files['subpath/to/ini_file.html.ini'] = (
- KNOWN_INI % ('Title: ini_file', 'abc'))
-
- adapter.import_(context, 'subpath/to')
- text = ini_file._was_put
- parser = ConfigParser()
- parser.readfp(StringIO(text))
- self.assertEqual(parser.get('DEFAULT', 'title'), 'Title: ini_file')
- self.assertEqual(parser.get('DEFAULT', 'description'), 'abc')
-
-
-class DAVAwareFileAdapterTests(unittest.TestCase,
- ConformsToIFilesystemExporter,
- ConformsToIFilesystemImporter,
- ):
-
- def _getTargetClass(self):
- from Products.CMFCore.exportimport.content import DAVAwareFileAdapter
- return DAVAwareFileAdapter
-
- def _makeOne(self, context, *args, **kw):
- return self._getTargetClass()(context, *args, **kw)
-
- def test_export_dav_file(self):
- dav_file = _makeDAVAware('dav_file.html')
- adapter = self._makeOne(dav_file)
- context = DummyExportContext(None)
- adapter.export(context, 'subpath/to')
-
- self.assertEqual(len(context._wrote), 1)
- filename, text, content_type = context._wrote[0]
- self.assertEqual(filename, 'subpath/to/dav_file.html')
- self.assertEqual(content_type, 'text/plain')
- self.assertEqual(text.strip(), dav_file.manage_FTPget().strip())
-
- def test_import_dav_file(self):
- VALUES = ('Title: dav_file', 'Description: abc', 'body goes here')
- dav_file = _makeDAVAware('dav_file.html')
- adapter = self._makeOne(dav_file)
- context = DummyImportContext(None)
- context._files['subpath/to/dav_file.html'] = KNOWN_DAV % VALUES
-
- adapter.import_(context, 'subpath/to')
- text = dav_file._was_put == KNOWN_DAV % VALUES
-
-
TEST_CSV_AWARE = 'Test CSV Aware'
KNOWN_CSV = """\
one,two,three
@@ -700,7 +530,7 @@
from OFS.SimpleItem import SimpleItem
from zope.interface import implements
from Products.CMFCore.interfaces import IDynamicType
- from Products.CMFCore.interfaces import ICSVAware
+ from Products.GenericSetup.interfaces import ICSVAware
class _TestCSVAware(SimpleItem):
implements(IDynamicType, ICSVAware)
@@ -733,7 +563,7 @@
from OFS.SimpleItem import SimpleItem
from zope.interface import implements
from Products.CMFCore.interfaces import IDynamicType
- from Products.CMFCore.interfaces import IINIAware
+ from Products.GenericSetup.interfaces import IINIAware
class _TestINIAware(SimpleItem):
implements(IDynamicType, IINIAware)
@@ -769,7 +599,7 @@
from OFS.SimpleItem import SimpleItem
from zope.interface import implements
from Products.CMFCore.interfaces import IDynamicType
- from Products.CMFCore.interfaces import IDAVAware
+ from Products.GenericSetup.interfaces import IDAVAware
class _TestDAVAware(SimpleItem):
implements(IDynamicType, IDAVAware)
@@ -787,6 +617,8 @@
def PUT(self, REQUEST, RESPONSE):
self._was_put = REQUEST.get('BODY', '')
+ stream = REQUEST.get('BODYFILE', None)
+ self._was_put_as_read = stream.read()
aware = _TestDAVAware()
aware._setId(id)
@@ -817,10 +649,7 @@
TEST_FOLDER = 'Test Folder'
def _makeFolder(id, site_folder=False):
- from zope.interface import directlyProvides
- from zope.interface import providedBy
from Products.CMFCore.PortalFolder import PortalFolder
- from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.TypesTool import TypesTool
from Products.CMFCore.tests.base.dummy import DummyType
@@ -847,7 +676,6 @@
folder = PortalFolder(id)
folder.portal_type = TEST_FOLDER
if site_folder:
- directlyProvides(folder, ISiteRoot + providedBy(folder))
tool = folder.portal_types = TypesTool()
tool._setObject(TEST_CSV_AWARE, _TypeInfo(TEST_CSV_AWARE))
tool._setObject(TEST_INI_AWARE, _TypeInfo(TEST_INI_AWARE))
@@ -860,10 +688,6 @@
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SiteStructureExporterTests))
- suite.addTest(unittest.makeSuite(Test_globpattern))
- suite.addTest(unittest.makeSuite(CSVAwareFileAdapterTests))
- suite.addTest(unittest.makeSuite(INIAwareFileAdapterTests))
- suite.addTest(unittest.makeSuite(DAVAwareFileAdapterTests))
return suite
if __name__ == '__main__':
Copied: CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_contenttyperegistry.py (from rev 40248, CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py)
Modified: CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_cookieauth.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_cookieauth.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_cookieauth.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -18,11 +18,7 @@
import unittest
import Testing
-import Products.CMFCore.exportimport
-import Products.Five
-from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
-
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.GenericSetup.testing import NodeAdapterTestCase
@@ -52,6 +48,9 @@
def setUp(self):
from Products.CMFCore.CookieCrumbler import CookieCrumbler
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
PlacelessSetup.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
Copied: CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_properties.py (from rev 40248, CMF/trunk/CMFCore/exportimport/tests/test_properties.py)
Modified: CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_typeinfo.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/exportimport/tests/test_typeinfo.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -20,11 +20,7 @@
import Zope2
Zope2.startup()
-import Products.CMFCore.exportimport
-import Products.Five
-from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
-
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.GenericSetup.testing import NodeAdapterTestCase
@@ -59,8 +55,32 @@
return TypeInformationNodeAdapter
+ def _populate(self, obj):
+ obj.addAction('foo_action', 'Foo', 'string:${object_url}/foo',
+ 'python:1', (), 'Bar')
+
+ def _verifyImport(self, obj):
+ self.assertEqual(type(obj._aliases), dict)
+ self.assertEqual(obj._aliases, {'(Default)': 'foo', 'view': 'foo'})
+ self.assertEqual(type(obj._aliases['view']), str)
+ self.assertEqual(obj._aliases['view'], 'foo')
+ self.assertEqual(type(obj._actions), tuple)
+ self.assertEqual(type(obj._actions[0].id), str)
+ self.assertEqual(obj._actions[0].id, 'foo_action')
+ self.assertEqual(type(obj._actions[0].title), str)
+ self.assertEqual(obj._actions[0].title, 'Foo')
+ self.assertEqual(type(obj._actions[0].description), str)
+ self.assertEqual(obj._actions[0].description, '')
+ self.assertEqual(type(obj._actions[0].category), str)
+ self.assertEqual(obj._actions[0].category, 'Bar')
+ self.assertEqual(type(obj._actions[0].condition.text), str)
+ self.assertEqual(obj._actions[0].condition.text, 'python:1')
+
def setUp(self):
from Products.CMFCore.TypesTool import FactoryTypeInformation
+ import Products.CMFCore.exportimport
+ import Products.Five
+ from Products.Five import zcml
PlacelessSetup.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
@@ -69,11 +89,7 @@
self._obj = FactoryTypeInformation('foo_fti')
self._XML = _FTI_XML
- def _populate(self, obj):
- obj.addAction('foo_action', 'Foo', 'string:${object_url}/foo',
- 'python:1', (), 'Bar')
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TypeInformationNodeAdapterTests),
Modified: CMF/branches/tseaver-viewification/CMFCore/fiveactionstool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/fiveactionstool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/fiveactionstool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -27,11 +27,23 @@
from utils import UniqueObject
from utils import _dtmldir
-from zope.app.publisher.browser.globalbrowsermenuservice import \
- globalBrowserMenuService
-from browser.globalbrowsermenuservice import getMenu
+try: # BBB (actually, FFF ;)
+ from zope.app.publisher.browser.globalbrowsermenuservice import \
+ globalBrowserMenuService
+except ImportError: # Zope3 > 3.0 loses services
+ from zope.app import zapi
+ from zope.app.publisher.interfaces.browser import IBrowserMenu
+ from zope.app.publisher.browser.menu import getMenu
+ def _listMenuIds():
+ return zapi.getUtilitiesFor(IBrowserMenu)
+else:
+ from browser.globalbrowsermenuservice import getMenu
+ def _listMenuIds():
+ return globalBrowserMenuService._registry.keys()
+
+
class FiveActionsTool(UniqueObject, SimpleItem, ActionProviderBase):
"""Five actions tool.
@@ -73,9 +85,9 @@
return ()
actions = []
- for mid in globalBrowserMenuService._registry.keys():
- menu = getMenu(mid, object, self.REQUEST)
- for entry in menu:
+
+ for menu_id in _listMenuIds():
+ for entry in getMenu(menu_id, object, self.REQUEST):
# The action needs a unique name, so we'll build one
# from the object_id and the action url. That is sure
# to be unique.
@@ -94,9 +106,10 @@
title=str(entry['title']),
action=Expression(text='string:%s' % action),
condition=filter,
- category=str(mid),
+ category=str(menu_id),
visible=1)
actions.append(act)
+
return tuple(actions)
Modified: CMF/branches/tseaver-viewification/CMFCore/interfaces/__init__.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/interfaces/__init__.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/interfaces/__init__.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -17,7 +17,6 @@
from _content import *
from _tools import *
-from _exportimport import *
import CachingPolicyManager
import Contentish
Deleted: CMF/branches/tseaver-viewification/CMFCore/interfaces/_exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/interfaces/_exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/interfaces/_exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,96 +0,0 @@
-""" Interfaces for content import / export, based on GenericSetup
-
-$Id$
-"""
-from zope.interface import Interface
-from zope.interface import Attribute
-
-class IFilesystemExporter(Interface):
- """ Plugin interface for site structure export.
- """
- def export(export_context, subdir):
- """ Export our 'context' using the API of 'export_context'.
-
- o 'export_context' must implement
- Products.GenericSupport.interfaces.IExportContext.
-
- o 'subdir', if passed, is the relative subdirectory containing our
- context within the site.
- """
-
- def listExportableItems():
- """ Return a sequence of the child items to be exported.
-
- o Each item in the returned sequence will be a tuple,
- (id, object, adapter) where adapter must implement
- IFilesystemExporter.
- """
-
-class IFilesystemImporter(Interface):
- """ Plugin interface for site structure export.
- """
- def import_(import_context, subdir):
- """ Import our 'context' using the API of 'import_context'.
-
- o 'import_context' must implement
- Products.GenericSupport.interfaces.IImportContext.
-
- o 'subdir', if passed, is the relative subdirectory containing our
- context within the site.
- """
-
-class ICSVAware(Interface):
- """ Interface for objects which dump / load 'text/comma-separated-values'.
- """
- def getId():
- """ Return the Zope id of the object.
- """
-
- def as_csv():
- """ Return a string representing the object as CSV.
- """
-
- def put_csv(fd):
- """ Parse CSV and update the object.
-
- o 'fd' must be a file-like object whose 'read' method returns
- CSV text parseable by the 'csv.reader'.
- """
-
-class IINIAware(Interface):
- """ Interface for objects which dump / load INI-format files..
- """
- def getId():
- """ Return the Zope id of the object.
- """
-
- def as_ini():
- """ Return a string representing the object as INI.
- """
-
- def put_ini(stream_or_text):
- """ Parse INI-formatted text and update the object.
-
- o 'stream_or_text' must be either a string, or else a stream
- directly parseable by ConfigParser.
- """
-
-class IDAVAware(Interface):
- """ Interface for objects which handle their own FTP / DAV operations.
- """
- def getId():
- """ Return the Zope id of the object.
- """
-
- def manage_FTPget():
- """ Return a string representing the object as a file.
- """
-
- def PUT(REQUEST, RESPONSE):
- """ Parse file content and update the object.
-
- o 'REQUEST' will have a 'get' method, which will have the
- content object in its "BODY" key. It will also have 'get_header'
- method, whose headers (e.g., "Content-Type") may affect the
- processing of the body.
- """
Modified: CMF/branches/tseaver-viewification/CMFCore/interfaces/_tools.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/interfaces/_tools.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/interfaces/_tools.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -225,6 +225,92 @@
#
# Caching policy tool interfaces
#
+class ICachingPolicy(Interface):
+
+ def getPolicyId():
+ """
+ """
+
+ def getPredicate():
+ """
+ """
+
+ def getMTimeFunc():
+ """
+ """
+
+ def getMaxAgeSecs():
+ """
+ """
+
+ def getSMaxAgeSecs():
+ """
+ """
+
+ def getNoCache():
+ """
+ """
+
+ def getNoStore():
+ """
+ """
+
+ def getMustRevalidate():
+ """
+ """
+
+ def getProxyRevalidate():
+ """
+ """
+
+ def getPublic():
+ """
+ """
+
+ def getPrivate():
+ """
+ """
+
+ def getNoTransform():
+ """
+ """
+
+ def getVary():
+ """
+ """
+
+ def getETagFunc():
+ """
+ """
+
+ def getEnable304s():
+ """
+ """
+
+ def getLastModified():
+ """Should we set the last modified header?
+ """
+
+ def getPreCheck():
+ """
+ """
+
+ def getPostCheck():
+ """
+ """
+
+ def testPredicate(expr_context):
+ """Does this request match our predicate?
+ """
+
+ def getHeaders(expr_context):
+ """Does this request match our predicate?
+
+ If so, return a sequence of caching headers as (key, value) tuples.
+ Otherwise, return an empty sequence.
+ """
+
+
class ICachingPolicyManager(Interface):
""" Compute HTTP cache headers for skin methods.
@@ -1427,17 +1513,6 @@
o Permission: Private (Python only)
"""
- def getActionsFor(ob):
- """ Return a list of action dictionaries for 'ob'
-
- o Generate the list as though queried via
- 'ActionsTool.listFilteredActionsFor'.
-
- o This method is deprecated and will be removed in CMF 1.7.
-
- o Permission: Public
- """
-
def doActionFor(ob, action, wf_id=None, *args, **kw):
""" Perform the given workflow action on 'ob'.
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/base/testcase.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/base/testcase.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/base/testcase.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -21,6 +21,15 @@
from security import AnonymousUser
from security import PermissiveSecurityPolicy
+try:
+ from zope.app.testing.placelesssetup import PlacelessSetup
+ from zope.app.testing.placelesssetup import setUp as placelessSetUp
+ from zope.app.testing.placelesssetup import tearDown as placelessTearDown
+except ImportError: # BBB, Zope3 < 3.1
+ from zope.app.tests.placelesssetup import PlacelessSetup
+ from zope.app.tests.placelesssetup import setUp as placelessSetUp
+ from zope.app.tests.placelesssetup import tearDown as placelessTearDown
+
class LogInterceptor:
_old_log_write = None
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_ActionsTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_ActionsTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_ActionsTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -18,6 +18,8 @@
import unittest
import Testing
+from Products.CMFCore.ActionInformation import Action
+from Products.CMFCore.ActionInformation import ActionCategory
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.Expression import Expression
from Products.CMFCore.MembershipTool import MembershipTool
@@ -25,7 +27,7 @@
from Products.CMFCore.URLTool import URLTool
-class ActionsToolTests(SecurityRequestTest):
+class ActionsToolTests(unittest.TestCase):
def _getTargetClass(self):
from Products.CMFCore.ActionsTool import ActionsTool
@@ -35,17 +37,6 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
- def setUp(self):
- SecurityRequestTest.setUp(self)
-
- root = self.root
- root._setObject( 'portal_actions', self._makeOne() )
- root._setObject( 'portal_url', URLTool() )
- root._setObject( 'foo', URLTool() )
- root._setObject('portal_membership', MembershipTool())
- self.tool = root.portal_actions
- self.tool.action_providers = ('portal_actions',)
-
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
@@ -64,12 +55,16 @@
verifyClass(IActionProvider, self._getTargetClass())
verifyClass(IActionsTool, self._getTargetClass())
- def test_actionProviders(self):
- tool = self.tool
+ def test_listActionProviders(self):
+ tool = self._makeOne()
+ tool.action_providers = ('portal_actions',)
self.assertEqual(tool.listActionProviders(), ('portal_actions',))
def test_addActionProvider(self):
- tool = self.tool
+ tool = self._makeOne()
+ tool.foo = 'acquirable attribute'
+ tool.portal_url = 'acquirable attribute'
+ tool.action_providers = ('portal_actions',)
tool.addActionProvider('foo')
self.assertEqual(tool.listActionProviders(),
('portal_actions', 'foo'))
@@ -78,12 +73,47 @@
self.assertEqual(tool.listActionProviders(),
('portal_actions', 'foo', 'portal_url'))
- def test_delActionProvider(self):
- tool = self.tool
+ def test_deleteActionProvider(self):
+ tool = self._makeOne()
+ tool.action_providers = ('portal_actions', 'foo')
tool.deleteActionProvider('foo')
- self.assertEqual(tool.listActionProviders(),
- ('portal_actions',))
+ self.assertEqual(tool.listActionProviders(), ('portal_actions',))
+ def test_getActionObject(self):
+ tool = self._makeOne()
+ tool._setObject('object', ActionCategory('object'))
+ tool.object._setObject('newstyle_id', Action('newstyle_id'))
+ tool.addAction('an_id', 'name', '', '', '', 'object')
+ rval = tool.getActionObject('object/an_id')
+ self.assertEqual(rval, tool._actions[0])
+ rval = tool.getActionObject('object/newstyle_id')
+ self.assertEqual(rval, None)
+ rval = tool.getActionObject('object/not_existing_id')
+ self.assertEqual(rval, None)
+ self.assertRaises(ValueError, tool.getActionObject, 'wrong_format')
+
+
+class ActionsToolSecurityRequestTests(SecurityRequestTest):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.ActionsTool import ActionsTool
+
+ return ActionsTool
+
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
+
+ def setUp(self):
+ SecurityRequestTest.setUp(self)
+
+ root = self.root
+ root._setObject( 'portal_actions', self._makeOne() )
+ root._setObject( 'portal_url', URLTool() )
+ root._setObject( 'foo', URLTool() )
+ root._setObject('portal_membership', MembershipTool())
+ self.tool = root.portal_actions
+ self.tool.action_providers = ('portal_actions',)
+
def test_listActionInformationActions(self):
# Check that listFilteredActionsFor works for objects that return
# ActionInformation objects
@@ -119,6 +149,7 @@
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(ActionsToolTests),
+ unittest.makeSuite(ActionsToolSecurityRequestTests),
))
if __name__ == '__main__':
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_CachingPolicyManager.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_CachingPolicyManager.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_CachingPolicyManager.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -14,27 +14,25 @@
$Id$
"""
+
+import unittest
+import Testing
+
import base64
import os
-from unittest import TestCase, TestSuite, makeSuite, main
-import Testing
-import Zope2
-Zope2.startup()
-
+from AccessControl.SecurityManagement import newSecurityManager
from App.Common import rfc1123_date
from DateTime.DateTime import DateTime
-from AccessControl.SecurityManagement import newSecurityManager
+from Products.CMFCore.FSPageTemplate import FSPageTemplate
+from Products.CMFCore.tests.base.dummy import DummyContent
+from Products.CMFCore.tests.base.dummy import DummySite
+from Products.CMFCore.tests.base.dummy import DummyTool
+from Products.CMFCore.tests.base.dummy import DummyUserFolder
+from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import RequestTest
-from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.test_FSPageTemplate import FSPTMaker
-from Products.CMFCore.tests.base.dummy import DummySite
-from Products.CMFCore.tests.base.dummy import DummyUserFolder
-from Products.CMFCore.tests.base.dummy import DummyContent
-from Products.CMFCore.tests.base.dummy import DummyTool
-from Products.CMFCore.FSPageTemplate import FSPageTemplate
-from Products.CMFCore import CachingPolicyManager
ACCLARK = DateTime( '2001/01/01' )
@@ -55,7 +53,7 @@
return self.modified
-class CachingPolicyTests(TestCase):
+class CachingPolicyTests(unittest.TestCase):
def setUp(self):
self._epoch = DateTime(0)
@@ -70,6 +68,13 @@
return createCPContext( DummyContent2(self._epoch)
, 'foo_view', kw, self._epoch )
+ def test_z3interfaces(self):
+ from zope.interface.verify import verifyClass
+ from Products.CMFCore.CachingPolicyManager import CachingPolicy
+ from Products.CMFCore.interfaces import ICachingPolicy
+
+ verifyClass(ICachingPolicy, CachingPolicy)
+
def test_empty( self ):
policy = self._makePolicy( 'empty' )
context = self._makeContext()
@@ -381,7 +386,7 @@
self.assertEqual( headers[2][1] , 'no-cache, no-store' )
-class CachingPolicyManagerTests(TestCase):
+class CachingPolicyManagerTests(unittest.TestCase):
def _makeOne(self, *args, **kw):
from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
@@ -422,15 +427,17 @@
)
self.assertEqual( len( headers ), 0 )
- self.assertRaises( KeyError, mgr._updatePolicy
- , 'xyzzy', None, None, None, None, None, None, '', '', None, None, None, None, None )
+ self.assertRaises( KeyError, mgr._updatePolicy,
+ 'xyzzy', None, None, None, None, None, None, '',
+ '', None, None, None, None, None )
self.assertRaises( KeyError, mgr._removePolicy, 'xyzzy' )
self.assertRaises( KeyError, mgr._reorderPolicy, 'xyzzy', -1 )
def test_addAndUpdatePolicy( self ):
mgr = self._makeOne()
- mgr.addPolicy( 'first', 'python:1', 'mtime', 1, 0, 1, 0, 'vary', 'etag', None, 2, 1, 0, 1, 0, 1, 0, 2, 3 )
+ mgr.addPolicy('first', 'python:1', 'mtime', 1, 0, 1, 0, 'vary',
+ 'etag', None, 2, 1, 0, 1, 0, 1, 0, 2, 3)
p = mgr._policies['first']
self.assertEqual(p.getPolicyId(), 'first')
self.assertEqual(p.getPredicate(), 'python:1')
@@ -451,7 +458,8 @@
self.assertEqual(p.getPreCheck(), 2)
self.assertEqual(p.getPostCheck(), 3)
- mgr.updatePolicy( 'first', 'python:0', 'mtime2', 2, 1, 0, 1, 'vary2', 'etag2', None, 1, 0, 1, 0, 1, 0, 1, 3, 2 )
+ mgr.updatePolicy('first', 'python:0', 'mtime2', 2, 1, 0, 1, 'vary2',
+ 'etag2', None, 1, 0, 1, 0, 1, 0, 1, 3, 2)
p = mgr._policies['first']
self.assertEqual(p.getPolicyId(), 'first')
self.assertEqual(p.getPredicate(), 'python:0')
@@ -595,6 +603,8 @@
class CachingPolicyManager304Tests(RequestTest, FSDVTest):
def setUp(self):
+ from Products.CMFCore import CachingPolicyManager
+
RequestTest.setUp(self)
FSDVTest.setUp(self)
@@ -668,12 +678,10 @@
etag_func = 'string:abc',
enable_304s = 0)
-
def tearDown(self):
RequestTest.tearDown(self)
FSDVTest.tearDown(self)
-
def _cleanup(self):
# Clean up request and response
req = self.portal.REQUEST
@@ -687,7 +695,6 @@
req.RESPONSE.setStatus(200)
-
def testUnconditionalGET(self):
# In this case the Request does not specify any if-modified-since
# value to take into account, thereby completely circumventing any
@@ -697,7 +704,6 @@
response = self.portal.REQUEST.RESPONSE
self.assertEqual(response.getStatus(), 200)
-
def testConditionalGETNoETag(self):
yesterday = DateTime() - 1
doc1 = self.portal.doc1
@@ -737,7 +743,6 @@
self.assertEqual(response.getStatus(), 200)
self._cleanup()
-
def testConditionalGETETag(self):
yesterday = DateTime() - 1
doc2 = self.portal.doc2
@@ -807,7 +812,6 @@
doc2()
self.assertEqual(response.getStatus(), 304)
self._cleanup()
-
def testConditionalGETDisabled(self):
yesterday = DateTime() - 1
@@ -835,12 +839,11 @@
def test_suite():
- return TestSuite((
- makeSuite(CachingPolicyTests),
- makeSuite(CachingPolicyManagerTests),
- makeSuite(CachingPolicyManager304Tests),
+ return unittest.TestSuite((
+ unittest.makeSuite(CachingPolicyTests),
+ unittest.makeSuite(CachingPolicyManagerTests),
+ unittest.makeSuite(CachingPolicyManager304Tests),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
-
+ unittest.main(defaultTest='test_suite')
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_CatalogTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_CatalogTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_CatalogTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -91,6 +91,7 @@
argument, 'idxs', to 'catalog_object'.
"""
tool = self._makeOne()
+ tool.addIndex('SearchableText', 'KeywordIndex')
dummy = DummyContent(catalog=1)
tool.catalog_object( dummy, '/dummy' )
@@ -98,6 +99,7 @@
def test_search_anonymous(self):
catalog = self._makeOne()
+ catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
dummy = DummyContent(catalog=1)
catalog.catalog_object(dummy, '/dummy')
@@ -106,6 +108,9 @@
def test_search_inactive(self):
catalog = self._makeOne()
+ catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+ catalog.addIndex('effective', 'DateIndex')
+ catalog.addIndex('expires', 'DateIndex')
now = DateTime()
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
@@ -128,6 +133,9 @@
def test_search_restrict_manager(self):
catalog = self._makeOne()
+ catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+ catalog.addIndex('effective', 'DateIndex')
+ catalog.addIndex('expires', 'DateIndex')
now = DateTime()
dummy = DummyContent(catalog=1)
@@ -159,6 +167,9 @@
def test_search_restrict_inactive(self):
catalog = self._makeOne()
+ catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+ catalog.addIndex('effective', 'DateIndex')
+ catalog.addIndex('expires', 'DateIndex')
now = DateTime()
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
@@ -189,6 +200,9 @@
def test_search_restrict_visible(self):
catalog = self._makeOne()
+ catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
+ catalog.addIndex('effective', 'DateIndex')
+ catalog.addIndex('expires', 'DateIndex')
now = DateTime()
dummy = DummyContent(catalog=1)
dummy._View_Permission = ('Blob',)
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_OpaqueItems.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_OpaqueItems.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_OpaqueItems.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -19,8 +19,14 @@
import Zope2
Zope2.startup()
+from zope.interface import implements
+
+from Products.CMFCore.interfaces import ICallableOpaqueItem
+from Products.CMFCore.interfaces import ICallableOpaqueItemEvents
from Products.CMFCore.interfaces.IOpaqueItems \
- import ICallableOpaqueItem, ICallableOpaqueItemEvents
+ import ICallableOpaqueItem as z2ICallableOpaqueItem
+from Products.CMFCore.interfaces.IOpaqueItems \
+ import ICallableOpaqueItemEvents as z2ICallableOpaqueItemEvents
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFCore.tests.base.dummy \
import DummyContent as OriginalDummyContent
@@ -90,15 +96,17 @@
class Marker(OpaqueBase):
""" Opaque item without manage_after/before hookes but marked as callable
"""
+ implements(ICallableOpaqueItem)
__implements__ = (
- ICallableOpaqueItem,
+ z2ICallableOpaqueItem,
)
class Hooks(OpaqueBase):
""" Opaque item with manage_after/before hooks but not marked as callable
"""
+ implements(ICallableOpaqueItemEvents)
__implements__ = (
- ICallableOpaqueItemEvents,
+ z2ICallableOpaqueItemEvents,
)
def manage_afterAdd(self, item, container):
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalContent.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalContent.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalContent.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -65,7 +65,7 @@
# Hack, we need a _p_mtime for the file, so we make sure that it
# has one. We use a subtransaction, which means we can rollback
# later and pretend we didn't touch the ZODB.
- #transaction.commit(1)
+ #transaction.savepoint(optimistic=True)
return [ self.root._getOb( folder_id ) for folder_id in FOLDER_IDS ]
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalFolder.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_PortalFolder.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,13 +15,12 @@
$Id$
"""
-from unittest import TestCase, TestSuite, makeSuite, main
+import unittest
import Testing
-import Zope2
-Zope2.startup()
import cStringIO
+import transaction
from AccessControl import SecurityManager
from AccessControl import Unauthorized
from Acquisition import aq_base
@@ -31,7 +30,6 @@
from OFS.Image import manage_addFile
from OFS.tests.testCopySupport import makeConnection
from Testing.makerequest import makerequest
-import transaction
from Products.CMFCore.CatalogTool import CatalogTool
from Products.CMFCore.exceptions import BadRequest
@@ -444,6 +442,7 @@
ttool = self.site._setObject( 'portal_types', TypesTool() )
ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+ ctool.addIndex('getId', 'FieldIndex')
self.assertEqual( len(ctool), 0 )
folder = self._makeOne('folder')
@@ -454,7 +453,7 @@
self.failUnless( has_path(ctool._catalog,
'/bar/site/folder/sub/foo') )
- transaction.commit(1)
+ transaction.savepoint(optimistic=True)
folder.manage_renameObject(id='sub', new_id='new_sub')
self.assertEqual( len(ctool), 1 )
self.failUnless( 'foo' in ctool.uniqueValuesFor('getId') )
@@ -473,7 +472,7 @@
sub2.all_meta_types.extend( sub2.all_meta_types )
sub2.all_meta_types.extend( extra_meta_types() )
- transaction.commit(1)
+ transaction.savepoint(optimistic=True)
cookie = folder.manage_cutObjects(ids=['bar'])
sub2.manage_pasteObjects(cookie)
@@ -523,7 +522,7 @@
self.failUnless( has_path(ctool._catalog, '/bar/site/sub2/dummy') )
self.failIf( has_path(ctool._catalog, '/bar/site/sub3/dummy') )
- transaction.commit(1)
+ transaction.savepoint(optimistic=True)
cookie = sub1.manage_cutObjects( ids = ('dummy',) )
# Waaa! force sub2 to allow paste of Dummy object.
sub3.all_meta_types = []
@@ -541,7 +540,7 @@
self.failUnless( has_path(ctool._catalog, '/bar/site/sub3/dummy') )
-class ContentFilterTests( TestCase ):
+class ContentFilterTests(unittest.TestCase):
def setUp( self ):
self.dummy=DummyContent('Dummy')
@@ -844,7 +843,7 @@
def allowed( self, object, object_roles=None ):
return self._lambdas[ 0 ]( object, object_roles )
-class PortalFolderCopySupportTests( TestCase ):
+class PortalFolderCopySupportTests(unittest.TestCase):
_old_policy = None
@@ -878,7 +877,7 @@
# Hack, we need a _p_mtime for the file, so we make sure that it
# has one. We use a subtransaction, which means we can rollback
# later and pretend we didn't touch the ZODB.
- transaction.commit(1)
+ transaction.savepoint(optimistic=True)
except:
self.connection.close()
raise
@@ -1104,7 +1103,7 @@
folder1.manage_permission( DeleteObjects, roles=(), acquire=0 )
folder1._setObject( 'sub', PortalFolder( 'sub' ) )
- transaction.commit(1) # get a _p_jar for 'sub'
+ transaction.savepoint(optimistic=True) # get a _p_jar for 'sub'
FOLDER_CTOR = 'manage_addProducts/CMFCore/manage_addPortalFolder'
folder2.all_meta_types = ( { 'name' : 'CMF Core Content'
@@ -1276,13 +1275,13 @@
def test_suite():
- return TestSuite((
- makeSuite( PortalFolderFactoryTests ),
- makeSuite( PortalFolderTests ),
- makeSuite( PortalFolderMoveTests ),
- makeSuite( ContentFilterTests ),
- makeSuite( PortalFolderCopySupportTests ),
+ return unittest.TestSuite((
+ unittest.makeSuite(PortalFolderFactoryTests),
+ unittest.makeSuite(PortalFolderTests),
+ unittest.makeSuite(PortalFolderMoveTests),
+ unittest.makeSuite(ContentFilterTests),
+ unittest.makeSuite(PortalFolderCopySupportTests),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_SkinsTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_SkinsTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_SkinsTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -91,10 +91,47 @@
self.failUnless(paths.find('.svn') == -1)
+class SkinnableTests(TestCase):
+
+ def _makeOne(self):
+ from Products.CMFCore.SkinsTool import SkinsTool
+ from Products.CMFCore.Skinnable import SkinnableObjectManager
+
+ class TestSkinnableObjectManager(SkinnableObjectManager):
+ tool = SkinsTool()
+ # This is needed otherwise REQUEST is the string
+ # '<Special Object Used to Force Acquisition>'
+ REQUEST = None
+ def getSkinsFolderName(self):
+ '''tool'''
+ return 'tool'
+
+ return TestSkinnableObjectManager()
+
+ def test_getCurrentSkinName(self):
+ som = self._makeOne()
+
+ pathA = ('foo, bar')
+ pathB = ('bar, foo')
+
+ som.tool.addSkinSelection('skinA', pathA)
+ som.tool.addSkinSelection('skinB', pathB)
+
+ som.tool.manage_properties(default_skin='skinA')
+
+ # Expect the default skin name to be returned
+ self.failUnless(som.getCurrentSkinName() == 'skinA')
+
+ # after a changeSkin the new skin name should be returned
+ som.changeSkin('skinB')
+ self.failUnless(som.getCurrentSkinName() == 'skinB')
+
+
def test_suite():
return TestSuite((
makeSuite(SkinsContainerTests),
makeSuite(SkinsToolTests),
+ makeSuite(SkinnableTests),
))
if __name__ == '__main__':
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_TypesTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_TypesTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_TypesTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -144,56 +144,7 @@
self.fail('CMF Collector issue #165 (Ownership bug): '
'Unauthorized raised' )
- def test_CMFCollector_49(self):
- #http://www.zope.org/Collectors/CMF/49
- #If you have two FTIs on the file system, both with the same meta_type
- #but with different id values, the way listDefaultTypeInformation
- #listed them in the dropdown list made it impossible to distinguish
- #the two because the identifier string only contained the CMF package
- #name and the meta_type
-
- # Extreme nastiness: Fake out a /Control_Panel/Products registry
- # inside the fake site by putting dummy objects with a
- # factory_type_information attribute on them...
- import copy
- fti1 = copy.deepcopy(FTIDATA_DUMMY)
- fti2 = copy.deepcopy(FTIDATA_DUMMY)
- fti2[0]['id'] = 'Other Content'
- product1 = DummyObject('product1')
- product1.factory_type_information = fti1 + fti2
- self.site._setObject('product1', product1)
- def fakeGetProducts(*ign, **igntoo):
- return self.site
- def fakeObjectValues(*ign, **igntoo):
- return (self.site.product1,)
- self.ttool._getProducts = fakeGetProducts
- self.site.objectValues = fakeObjectValues
-
- types = self.ttool.listDefaultTypeInformation()
- dropdown_representation = [x[0] for x in types]
- self.failIf(dropdown_representation[0]==dropdown_representation[1])
-
- # Backwards-compatibility tests
- # Make sure the old representation still works, for now
- ti_factory = self.ttool.manage_addTypeInformation
- ti_type = 'Factory-based Type Information'
- new_repr = 'product1: Dummy Content (Dummy)'
- old_repr = 'product1: Dummy'
-
- # This one uses the new representation. We do not expect an Exception
- ti_factory(ti_type, id='NewType1', typeinfo_name=new_repr)
- self.failUnless('NewType1' in self.ttool.objectIds())
-
- # Now try with the old representation, which will throw a BadRequest
- # unless the workaround in the code is used
- self._trap_warning_output()
- ti_factory(ti_type, id='NewType2', typeinfo_name=old_repr)
- self.failUnless('NewType2' in self.ttool.objectIds())
- self.failUnless('DeprecationWarning' in
- self._our_stderr_stream.getvalue())
-
-
class TypeInfoTests(TestCase):
def _makeTypesTool(self):
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_WorkflowTool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_WorkflowTool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_WorkflowTool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,10 +15,8 @@
$Id$
"""
-from unittest import TestCase, TestSuite, makeSuite, main
+import unittest
import Testing
-import Zope2
-Zope2.startup()
from OFS.SimpleItem import SimpleItem
@@ -133,7 +131,7 @@
return None
-class WorkflowToolTests(TestCase, WarningInterceptor):
+class WorkflowToolTests(unittest.TestCase, WarningInterceptor):
def setUp( self ):
from Products.CMFCore.WorkflowTool import addWorkflowFactory
@@ -291,18 +289,6 @@
self.failUnless( 'dummy' in vars.keys() )
self.failUnless( 'a: dummy' in vars.values() )
- def test_getActionsFor( self ):
-
- import warnings
-
- # Collector #360: Test AtttributeError in deprecated API :(
- tool = self._makeWithTypesAndChain()
- dummy = DummyContent( 'dummy' )
-
- self._trap_warning_output()
- actions = tool.getActionsFor( dummy )
- self.assertEqual( len( actions ), 0 )
-
def test_getInfoFor( self ):
tool = self._makeWithTypesAndChain()
@@ -383,9 +369,9 @@
def test_suite():
- return TestSuite((
- makeSuite(WorkflowToolTests),
+ return unittest.TestSuite((
+ unittest.makeSuite(WorkflowToolTests),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
Deleted: CMF/branches/tseaver-viewification/CMFCore/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,64 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFCore tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite('Products.CMFCore.tests',[
- 'test_ActionInformation',
- 'test_ActionProviderBase',
- 'test_ActionsTool',
- 'test_CachingPolicyManager',
- 'test_CatalogTool',
- 'test_ContentTypeRegistry',
- 'test_DirectoryView',
- 'test_DiscussionTool',
- 'test_DynamicType',
- 'test_Expression',
- 'test_FSFile',
- 'test_FSImage',
- 'test_FSMetadata',
- 'test_FSPageTemplate',
- 'test_FSPythonScript',
- 'test_FSSecurity',
- 'test_MemberDataTool',
- 'test_MembershipTool',
- 'test_OpaqueItems',
- 'test_PortalContent',
- 'test_PortalFolder',
- 'test_RegistrationTool',
- 'test_SkinsTool',
- 'test_TypesTool',
- 'test_UndoTool',
- 'test_URLTool',
- 'test_utils',
- 'test_WorkflowTool',
- 'testCookieCrumbler',
- ])
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
Modified: CMF/branches/tseaver-viewification/CMFCore/tests/test_fiveactionstool.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/tests/test_fiveactionstool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/tests/test_fiveactionstool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -26,8 +26,9 @@
Some basic setup:
- >>> from zope.app.tests.placelesssetup import setUp, tearDown
- >>> setUp()
+ >>> from Products.CMFCore.tests.base.testcase import placelessSetUp
+ >>> from Products.CMFCore.tests.base.testcase import placelessTearDown
+ >>> placelessSetUp()
>>> import Products.Five
>>> import Products.CMFCore
@@ -75,7 +76,7 @@
Cleanup:
- >>> tearDown()
+ >>> placelessTearDown()
"""
def test_suite():
Modified: CMF/branches/tseaver-viewification/CMFCore/utils.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFCore/utils.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFCore/utils.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -46,14 +46,18 @@
from OFS.SimpleItem import SimpleItem
from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter
-from zope.i18nmessageid import MessageIDFactory
from thread import allocate_lock
from exceptions import AccessControl_Unauthorized
from exceptions import NotFound
from warnings import warn
+try:
+ from zope.i18nmessageid import MessageFactory
+except ImportError: # BBB
+ from zope.i18nmessageid import MessageIDFactory as MessageFactory
+
security = ModuleSecurityInfo( 'Products.CMFCore.utils' )
_dtmldir = os_path.join( package_home( globals() ), 'dtml' )
@@ -594,11 +598,11 @@
, extra_constructors=()
, fti=()
):
+ # BBB: fti argument is ignored
self.meta_type = meta_type
self.content_types = content_types
self.permission = permission
self.extra_constructors = extra_constructors
- self.fti = fti
def initialize(self, context):
# Add only one meta type to the folder add list.
@@ -609,9 +613,7 @@
# manage_addContentType() can then grab it.
, constructors = ( manage_addContentForm
, manage_addContent
- , self
- , ('factory_type_information', self.fti)
- ) + self.extra_constructors
+ , self ) + self.extra_constructors
, permission = self.permission
)
@@ -794,4 +796,4 @@
security.declarePublic('MessageID')
-MessageID = MessageIDFactory('cmf_default')
+MessageID = MessageFactory('cmf_default')
Modified: CMF/branches/tseaver-viewification/CMFDefault/DEPENDENCIES.txt
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/DEPENDENCIES.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/DEPENDENCIES.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,5 +1,4 @@
Zope >= 2.8.2
Five >= 1.2
CMFCore
-CMFTopic
GenericSetup
Modified: CMF/branches/tseaver-viewification/CMFDefault/DefaultWorkflow.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/DefaultWorkflow.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/DefaultWorkflow.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -46,7 +46,7 @@
implements(IWorkflowDefinition)
__implements__ = z2IWorkflowDefinition
- meta_type = 'Workflow'
+ meta_type = 'CMF Default Workflow'
id = 'default_workflow'
title = 'Simple Review / Publish Policy'
_isAWorkflow = 1
Modified: CMF/branches/tseaver-viewification/CMFDefault/DiscussionItem.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/DiscussionItem.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/DiscussionItem.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -40,34 +40,8 @@
from utils import scrubHTML
-factory_type_information = (
- { 'id' : 'Discussion Item'
- , 'meta_type' : 'Discussion Item'
- , 'description' : """\
-Discussion Items are documents which reply to other content.
-They should *not* be addable through the standard 'folder_factories' interface.
-"""
- , 'icon' : 'discussionitem_icon.gif'
- , 'product' : '' # leave blank to suppress
- , 'factory' : ''
- , 'immediate_view' : ''
- , 'aliases' : {'(Default)':'discussionitem_view',
- 'view':'discussionitem_view'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/discussionitem_view'
- , 'permissions' : (View,)
- }
- ,
- )
- }
-,
-)
-
-
def addDiscussionItem(self, id, title, description, text_format, text,
reply_to, RESPONSE=None):
-
""" Add a discussion item
'title' is also used as the subject header
@@ -442,4 +416,4 @@
return [ x[0] for x in result ]
-InitializeClass( DiscussionItemContainer )
+InitializeClass(DiscussionItemContainer)
Modified: CMF/branches/tseaver-viewification/CMFDefault/Document.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/Document.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/Document.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -28,6 +28,7 @@
from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.utils import contributorsplitter
from Products.CMFCore.utils import keywordsplitter
+from Products.GenericSetup.interfaces import IDAVAware
from DublinCore import DefaultDublinCoreImpl
from exceptions import EditingConflict
@@ -45,52 +46,20 @@
from utils import parseHeadersBody
from utils import SimpleHTMLParser
-factory_type_information = (
- { 'id' : 'Document'
- , 'meta_type' : 'Document'
- , 'description' : """\
-Documents contain text that can be formatted using 'Structured Text.'
-They may also contain HTML, or "plain" text.
-"""
- , 'icon' : 'document_icon.gif'
- , 'product' : 'CMFDefault'
- , 'factory' : 'addDocument'
- , 'immediate_view' : 'metadata_edit_form'
- , 'aliases' : {'(Default)':'document_view',
- 'view':'document_view',
- 'gethtml':'source_html'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/document_view'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/document_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- , { 'id' : 'metadata'
- , 'name' : 'Metadata'
- , 'action': 'string:${object_url}/metadata_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- )
- }
-,
-)
-def addDocument(self, id, title='', description='', text_format='',
- text=''):
- """ Add a Document """
+def addDocument(self, id, title='', description='', text_format='', text=''):
+ """Add a Document.
+ """
o = Document(id, title, description, text_format, text)
self._setObject(id,o)
class Document(PortalContent, DefaultDublinCoreImpl):
- """ A Document - Handles both StructuredText and HTML """
+ """A Document - Handles both StructuredText and HTML.
+ """
- implements(IDocument, IMutableDocument)
+ implements(IDocument, IMutableDocument, IDAVAware)
__implements__ = (z2IDocument, z2IMutableDocument,
PortalContent.__implements__,
DefaultDublinCoreImpl.__implements__)
Modified: CMF/branches/tseaver-viewification/CMFDefault/Favorite.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/Favorite.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/Favorite.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -23,47 +23,14 @@
from Products.CMFCore.utils import getToolByName
-from permissions import View
-from permissions import ModifyPortalContent
from DublinCore import DefaultDublinCoreImpl
from Link import Link
+from permissions import View
-factory_type_information = (
- { 'id' : 'Favorite'
- , 'meta_type' : 'Favorite'
- , 'description' : """\
-A Favorite is a Link to an intra-portal resource.
-"""
- , 'icon' : 'link_icon.gif'
- , 'product' : 'CMFDefault'
- , 'factory' : 'addFavorite'
- , 'immediate_view' : 'metadata_edit_form'
- , 'aliases' : {'(Default)':'favorite_view',
- 'view':'favorite_view'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/favorite_view'
- , 'permissions' : ( View, )
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/link_edit_form'
- , 'permissions' : ( ModifyPortalContent, )
- }
- , { 'id' : 'metadata'
- , 'name' : 'Metadata'
- , 'action': 'string:${object_url}/metadata_edit_form'
- , 'permissions' : ( ModifyPortalContent, )
- }
- )
- }
-,
-)
def addFavorite(self, id, title='', remote_url='', description=''):
+ """Add a Favorite.
"""
- Add a Favorite
- """
portal_url = getToolByName(self, 'portal_url')
portal_obj = portal_url.getPortalObject()
content_obj = portal_obj.restrictedTraverse( remote_url )
@@ -73,10 +40,10 @@
self._setObject(id,o)
-class Favorite( Link ):
+class Favorite(Link):
+
+ """A Favorite (special kind of Link).
"""
- A Favorite (special kind of Link)
- """
__implements__ = Link.__implements__ # redundant, but explicit
@@ -215,5 +182,4 @@
# save unique id of favorite
self.remote_uid = self._getUidByUrl()
-
InitializeClass(Favorite)
Modified: CMF/branches/tseaver-viewification/CMFDefault/File.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/File.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/File.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -17,55 +17,19 @@
$Id$
"""
+import OFS.Image
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
+from zope.interface import implements
from Products.CMFCore.PortalContent import PortalContent
+from Products.GenericSetup.interfaces import IDAVAware
from DublinCore import DefaultDublinCoreImpl
-from permissions import View
from permissions import ModifyPortalContent
+from permissions import View
-factory_type_information = (
- { 'id' : 'File'
- , 'meta_type' : 'Portal File'
- , 'description' : """\
-File objects can contain arbitrary downloadable files.
-"""
- , 'icon' : 'file_icon.gif'
- , 'product' : 'CMFDefault'
- , 'factory' : 'addFile'
- , 'immediate_view' : 'metadata_edit_form'
- , 'aliases' : {'(Default)':'index_html',
- 'view':'file_view'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/file_view'
- , 'permissions' : (View,)
- }
- , { 'id' : 'download'
- , 'name' : 'Download'
- , 'action': 'string:${object_url}'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/file_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- , { 'id' : 'metadata'
- , 'name' : 'Metadata'
- , 'action': 'string:${object_url}/metadata_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- )
- }
-,
-)
-
-import OFS.Image
-
def addFile( self
, id
, title=''
@@ -105,13 +69,10 @@
self._getOb(id).manage_upload(file)
-class File( OFS.Image.File
- , PortalContent
- , DefaultDublinCoreImpl
- ):
+class File(OFS.Image.File, PortalContent, DefaultDublinCoreImpl):
+
+ """A Portal-managed File.
"""
- A Portal-managed File
- """
# The order of base classes is very significant in this case.
# Image.File does not store it's id in it's 'id' attribute.
@@ -126,6 +87,7 @@
# this problem altogether. getId is the new way, accessing .id is
# deprecated.
+ implements(IDAVAware)
__implements__ = ( PortalContent.__implements__
, DefaultDublinCoreImpl.__implements__
)
@@ -259,6 +221,4 @@
OFS.Image.File.PUT( self, REQUEST, RESPONSE )
self.reindexObject()
-
InitializeClass(File)
-
Modified: CMF/branches/tseaver-viewification/CMFDefault/Image.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/Image.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/Image.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -16,49 +16,19 @@
$Id$
"""
-from Globals import InitializeClass
+import OFS.Image
from AccessControl import ClassSecurityInfo
+from Globals import InitializeClass
+from zope.interface import implements
from Products.CMFCore.PortalContent import PortalContent
+from Products.GenericSetup.interfaces import IDAVAware
from DublinCore import DefaultDublinCoreImpl
-from permissions import View
from permissions import ModifyPortalContent
+from permissions import View
-factory_type_information = (
- { 'id' : 'Image'
- , 'meta_type' : 'Portal Image'
- , 'description' : """\
-Image objects can be embedded in Portal documents.
-"""
- , 'icon' : 'image_icon.gif'
- , 'product' : 'CMFDefault'
- , 'factory' : 'addImage'
- , 'immediate_view' : 'metadata_edit_form'
- , 'aliases' : {'(Default)':'index_html',
- 'view':'image_view'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/image_view'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/image_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- , { 'id' : 'metadata'
- , 'name' : 'Metadata'
- , 'action': 'string:${object_url}/metadata_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- )
- }
-,
-)
-import OFS.Image
-
def addImage( self
, id
, title=''
@@ -97,13 +67,10 @@
self._getOb(id).manage_upload(file)
-class Image( OFS.Image.Image
- , PortalContent
- , DefaultDublinCoreImpl
- ):
+class Image(OFS.Image.Image, PortalContent, DefaultDublinCoreImpl):
+
+ """A Portal-managed Image.
"""
- A Portal-managed Image
- """
# The order of base classes is very significant in this case.
# Image.Image does not store it's id in it's 'id' attribute.
@@ -118,6 +85,7 @@
# this problem altogether. getId is the new way, accessing .id is
# deprecated.
+ implements(IDAVAware)
__implements__ = ( PortalContent.__implements__
, DefaultDublinCoreImpl.__implements__
)
@@ -242,5 +210,3 @@
self.reindexObject()
InitializeClass(Image)
-
-
Modified: CMF/branches/tseaver-viewification/CMFDefault/Link.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/Link.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/Link.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -17,16 +17,18 @@
import urlparse
+import transaction
from AccessControl import ClassSecurityInfo
from Globals import DTMLFile
from Globals import InitializeClass
-import transaction
from zope.interface import implements
+from zope.interface import implements
from Products.CMFCore.interfaces import IMutableDublinCore
from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.utils import contributorsplitter
from Products.CMFCore.utils import keywordsplitter
+from Products.GenericSetup.interfaces import IDAVAware
from DublinCore import DefaultDublinCoreImpl
from exceptions import ResourceLockedError
@@ -40,37 +42,6 @@
from utils import formatRFC822Headers
from utils import parseHeadersBody
-factory_type_information = (
- { 'id' : 'Link'
- , 'meta_type' : 'Link'
- , 'description' : """\
-Link items are annotated URLs.
-"""
- , 'icon' : 'link_icon.gif'
- , 'product' : 'CMFDefault'
- , 'factory' : 'addLink'
- , 'immediate_view' : 'metadata_edit_form'
- , 'aliases' : {'(Default)':'link_view',
- 'view':'link_view'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/link_view'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/link_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- , { 'id' : 'metadata'
- , 'name' : 'Metadata'
- , 'action': 'string:${object_url}/metadata_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- )
- }
-,
-)
def addLink( self
, id
@@ -78,21 +49,22 @@
, remote_url=''
, description=''
):
+ """Add a Link instance to 'self'.
"""
- Add a Link instance to 'self'.
- """
o=Link( id, title, remote_url, description )
self._setObject(id,o)
-class Link( PortalContent
- , DefaultDublinCoreImpl
- ):
+class Link(PortalContent, DefaultDublinCoreImpl):
+
+ """A Link.
"""
- A Link
- """
- implements(ILink, IMutableLink, IMutableDublinCore)
+ implements( ILink
+ , IMutableLink
+ , IMutableDublinCore
+ , IDAVAware
+ )
__implements__ = ( z2ILink
, z2IMutableLink
, PortalContent.__implements__
@@ -238,4 +210,4 @@
"""
return len(self.manage_FTPget())
-InitializeClass( Link )
+InitializeClass(Link)
Modified: CMF/branches/tseaver-viewification/CMFDefault/NewsItem.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/NewsItem.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/NewsItem.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -22,39 +22,6 @@
from permissions import ModifyPortalContent
from permissions import View
-factory_type_information = (
- { 'id' : 'News Item'
- , 'meta_type' : 'News Item'
- , 'description' : """\
-News Items contain short text articles and carry a title as well as
-an optional description.
-"""
- , 'icon' : 'newsitem_icon.gif'
- , 'product' : 'CMFDefault'
- , 'factory' : 'addNewsItem'
- , 'immediate_view' : 'metadata_edit_form'
- , 'aliases' : {'(Default)':'newsitem_view',
- 'view':'newsitem_view',
- 'gethtml':'source_html'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/newsitem_view'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/newsitem_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- , { 'id' : 'metadata'
- , 'name' : 'Metadata'
- , 'action': 'string:${object_url}/metadata_edit_form'
- , 'permissions' : (ModifyPortalContent,)
- }
- )
- }
-,
-)
def addNewsItem( self
, id
@@ -63,9 +30,8 @@
, text=''
, text_format=''
):
+ """Add a NewsItem.
"""
- Add a NewsItem
- """
o=NewsItem( id=id
, title=title
, description=description
@@ -75,10 +41,10 @@
self._setObject(id, o)
-class NewsItem( Document ):
+class NewsItem(Document):
+
+ """A News Item.
"""
- A News Item
- """
__implements__ = Document.__implements__ # redundant, but explicit
@@ -98,4 +64,4 @@
self.setDescription( description )
Document.edit( self, text_format, text )
-InitializeClass( NewsItem )
+InitializeClass(NewsItem)
Modified: CMF/branches/tseaver-viewification/CMFDefault/Portal.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/Portal.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/Portal.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,57 +15,18 @@
$Id$
"""
-from warnings import warn
-
from Globals import InitializeClass
from Products.CMFCore.PortalObject import PortalObjectBase
-from Products.CMFCore import PortalFolder
-from Products.CMFCore.TypesTool import FactoryTypeInformation
-from Products.CMFCore.utils import getToolByName
-# This SkinnedFolder import is a workaround for circular imports in CMFTopic
-import Products.CMFDefault.SkinnedFolder
-from Products.CMFTopic import Topic
-from Products.CMFTopic import topic_globals
-
from DublinCore import DefaultDublinCoreImpl
from permissions import AddPortalContent
from permissions import AddPortalFolders
-from permissions import DeleteObjects
-from permissions import FTPAccess
from permissions import ListPortalMembers
-from permissions import ListUndoableChanges
-from permissions import ManagePortal
-from permissions import ManageProperties
from permissions import ReplyToItem
-from permissions import ReviewPortalContent
-from permissions import SetOwnPassword
-from permissions import SetOwnProperties
-from permissions import UndoChanges
from permissions import View
-from permissions import ViewManagementScreens
-import Document
-import Image
-import File
-import Link
-import NewsItem
-import Favorite
-import DiscussionItem
-import SkinnedFolder
-factory_type_information = ( Document.factory_type_information
- + Image.factory_type_information
- + File.factory_type_information
- + Link.factory_type_information
- + NewsItem.factory_type_information
- + Favorite.factory_type_information
- + DiscussionItem.factory_type_information
- + SkinnedFolder.factory_type_information
- )
-
-
class CMFSite(PortalObjectBase, DefaultDublinCoreImpl):
"""
@@ -106,201 +67,3 @@
pass
InitializeClass(CMFSite)
-
-
-class PortalGenerator:
-
- klass = CMFSite
-
- def setupTools(self, p):
- """Set up initial tools"""
-
- addCMFCoreTool = p.manage_addProduct['CMFCore'].manage_addTool
- addCMFCoreTool('CMF Actions Tool', None)
- addCMFCoreTool('CMF Catalog', None)
- addCMFCoreTool('CMF Member Data Tool', None)
- addCMFCoreTool('CMF Skins Tool', None)
- addCMFCoreTool('CMF Types Tool', None)
- addCMFCoreTool('CMF Undo Tool', None)
- addCMFCoreTool('CMF URL Tool', None)
- addCMFCoreTool('CMF Workflow Tool', None)
-
- addCMFDefaultTool = p.manage_addProduct['CMFDefault'].manage_addTool
- addCMFDefaultTool('Default Discussion Tool', None)
- addCMFDefaultTool('Default Membership Tool', None)
- addCMFDefaultTool('Default Registration Tool', None)
- addCMFDefaultTool('Default Properties Tool', None)
- addCMFDefaultTool('Default Metadata Tool', None)
- addCMFDefaultTool('Default Syndication Tool', None)
-
- # try to install CMFUid without raising exceptions if not available
- try:
- addCMFUidTool = p.manage_addProduct['CMFUid'].manage_addTool
- except AttributeError:
- pass
- else:
- addCMFUidTool('Unique Id Annotation Tool', None)
- addCMFUidTool('Unique Id Generator Tool', None)
- addCMFUidTool('Unique Id Handler Tool', None)
-
- def setupMailHost(self, p):
- p.manage_addProduct['MailHost'].manage_addMailHost(
- 'MailHost', smtp_host='localhost')
-
- def setupUserFolder(self, p):
- p.manage_addProduct['OFSP'].manage_addUserFolder()
-
- def setupCookieAuth(self, p):
- p.manage_addProduct['CMFCore'].manage_addCC(
- id='cookie_authentication')
-
- def setupMembersFolder(self, p):
- PortalFolder.manage_addPortalFolder(p, 'Members')
- p.Members.manage_addProduct['OFSP'].manage_addDTMLMethod(
- 'index_html', 'Member list', '<dtml-return roster>')
-
- def setupRoles(self, p):
- # Set up the suggested roles.
- p.__ac_roles__ = ('Member', 'Reviewer',)
-
- def setupPermissions(self, p):
- # Set up some suggested role to permission mappings.
- mp = p.manage_permission
-
- mp(AddPortalContent, ['Owner','Manager',], 1)
- mp(AddPortalFolders, ['Owner','Manager',], 1)
- mp(ListPortalMembers, ['Member','Manager',], 1)
- mp(ListUndoableChanges, ['Member','Manager',], 1)
- mp(ReplyToItem, ['Member','Manager',], 1)
- mp(ReviewPortalContent, ['Reviewer','Manager',], 1)
- mp(SetOwnPassword, ['Member','Manager',], 1)
- mp(SetOwnProperties, ['Member','Manager',], 1)
-
- # Add some other permissions mappings that may be helpful.
- mp(DeleteObjects, ['Owner','Manager',], 1)
- mp(FTPAccess, ['Owner','Manager',], 1)
- mp(ManageProperties, ['Owner','Manager',], 1)
- mp(UndoChanges, ['Owner','Manager',], 1)
- mp(ViewManagementScreens, ['Owner','Manager',], 1)
-
- def setupDefaultSkins(self, p):
- from Products.CMFCore.DirectoryView import addDirectoryViews
- ps = getToolByName(p, 'portal_skins')
- addDirectoryViews(ps, 'skins', globals())
- addDirectoryViews(ps, 'skins', topic_globals)
- ps.manage_addProduct['OFSP'].manage_addFolder(id='custom')
- ps.addSkinSelection('Basic',
- 'custom, zpt_topic, zpt_content, zpt_generic,'
- + 'zpt_control, Images',
- make_default=1)
- p.setupCurrentSkin()
-
- def setupTypes(self, p, initial_types=factory_type_information):
- tool = getToolByName(p, 'portal_types', None)
- if tool is None:
- return
- for t in initial_types:
- fti = FactoryTypeInformation(**t)
- tool._setObject(t['id'], fti)
-
- def setupMimetypes(self, p):
- p.manage_addProduct[ 'CMFCore' ].manage_addRegistry()
- reg = p.content_type_registry
-
- reg.addPredicate( 'link', 'extension' )
- reg.getPredicate( 'link' ).edit( extensions="url, link" )
- reg.assignTypeName( 'link', 'Link' )
-
- reg.addPredicate( 'news', 'extension' )
- reg.getPredicate( 'news' ).edit( extensions="news" )
- reg.assignTypeName( 'news', 'News Item' )
-
- reg.addPredicate( 'document', 'major_minor' )
- reg.getPredicate( 'document' ).edit( major="text", minor="" )
- reg.assignTypeName( 'document', 'Document' )
-
- reg.addPredicate( 'image', 'major_minor' )
- reg.getPredicate( 'image' ).edit( major="image", minor="" )
- reg.assignTypeName( 'image', 'Image' )
-
- reg.addPredicate( 'file', 'major_minor' )
- reg.getPredicate( 'file' ).edit( major="application", minor="" )
- reg.assignTypeName( 'file', 'File' )
-
- def setupWorkflow(self, p):
- wftool = getToolByName(p, 'portal_workflow', None)
- if wftool is None:
- return
- try:
- from Products.DCWorkflow.Default \
- import createDefaultWorkflowClassic
- except ImportError:
- return
- id = 'default_workflow'
- wftool._setObject( id, createDefaultWorkflowClassic(id) )
-
- # These objects don't participate in workflow by default.
- wftool.setChainForPortalTypes( ('Folder', 'Topic'), () )
-
- def setup(self, p, create_userfolder):
- self.setupTools(p)
- self.setupMailHost(p)
- if int(create_userfolder) != 0:
- self.setupUserFolder(p)
- self.setupCookieAuth(p)
- self.setupMembersFolder(p)
- self.setupRoles(p)
- self.setupPermissions(p)
- self.setupDefaultSkins(p)
-
- # SkinnedFolders are only for customization;
- # they aren't a default type.
- default_types = tuple( filter( lambda x: x['id'] != 'Skinned Folder'
- , factory_type_information ) )
- self.setupTypes(p, default_types )
-
- self.setupTypes(p, PortalFolder.factory_type_information)
- self.setupTypes(p, Topic.factory_type_information)
- self.setupMimetypes(p)
- self.setupWorkflow(p)
-
- def create(self, parent, id, create_userfolder):
- id = str(id)
- portal = self.klass(id=id)
- parent._setObject(id, portal)
- # Return the fully wrapped object.
- p = parent.this()._getOb(id)
- self.setup(p, create_userfolder)
- return p
-
- def setupDefaultProperties(self, p, title, description,
- email_from_address, email_from_name,
- validate_email, default_charset=''):
- p._setProperty('email_from_address', email_from_address, 'string')
- p._setProperty('email_from_name', email_from_name, 'string')
- p._setProperty('validate_email', validate_email and 1 or 0, 'boolean')
- p._setProperty('default_charset', default_charset, 'string')
- p._setProperty('enable_permalink', 0, 'boolean')
- p.title = title
- p.description = description
-
-
-def manage_addCMFSite(self, id, title='Portal', description='',
- create_userfolder=1,
- email_from_address='postmaster at localhost',
- email_from_name='Portal Administrator',
- validate_email=0, default_charset='',
- RESPONSE=None):
- """ Adds a portal instance.
- """
- warn('manage_addCMFSite() is deprecated and will be removed in CMF 1.7. '
- 'Please use addConfiguredSite() instead.',
- DeprecationWarning)
- gen = PortalGenerator()
- id = id.strip()
- p = gen.create(self, id, create_userfolder)
- gen.setupDefaultProperties(p, title, description,
- email_from_address, email_from_name,
- validate_email, default_charset)
- if RESPONSE is not None:
- RESPONSE.redirect(p.absolute_url() + '/finish_portal_construction')
Modified: CMF/branches/tseaver-viewification/CMFDefault/SkinnedFolder.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/SkinnedFolder.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/SkinnedFolder.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -22,61 +22,15 @@
from Products.CMFCore.PortalFolder import PortalFolder
from DublinCore import DefaultDublinCoreImpl
-from permissions import AddPortalContent
-from permissions import ListFolderContents
-from permissions import ManageProperties
from permissions import ModifyPortalContent
from permissions import View
-factory_type_information = (
- { 'id' : 'Skinned Folder'
- , 'meta_type' : 'Skinned Folder'
- , 'description' : """\
-Skinned folders can define custom 'view' actions.
-"""
- , 'icon' : 'folder_icon.gif'
- , 'product' : 'CMFDefault'
- , 'factory' : 'addSkinnedFolder'
- , 'filter_content_types' : 0
- , 'immediate_view' : 'folder_edit_form'
- , 'aliases' : {'(Default)': 'folder_view',
- 'view': 'folder_view'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/folder_view'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/folder_edit_form'
- , 'permissions' : (ManageProperties,)
- }
- , { 'id' : 'folderContents'
- , 'name' : 'Folder contents'
- , 'action': 'string:${object_url}/folder_contents'
- , 'permissions' : (ListFolderContents,)
- }
- , { 'id' : 'new'
- , 'name' : 'New...'
- , 'action': 'string:${object_url}/folder_factories'
- , 'permissions' : (AddPortalContent,)
- , 'visible' : 0
- }
- , { 'id' : 'rename_items'
- , 'name' : 'Rename items'
- , 'action': 'string:${object_url}/folder_rename_form'
- , 'permissions' : (AddPortalContent,)
- , 'visible' : 0
- }
- )
- }
-,
-)
-
class SkinnedFolder(CMFCatalogAware, PortalFolder):
+
""" Skinned Folder class.
"""
+
meta_type = 'Skinned Folder'
security = ClassSecurityInfo()
@@ -104,7 +58,7 @@
# We derive from CMFCatalogAware first, so we are cataloged too.
-InitializeClass( SkinnedFolder )
+InitializeClass(SkinnedFolder)
def addSkinnedFolder( self, id, title='', description='', REQUEST=None ):
Modified: CMF/branches/tseaver-viewification/CMFDefault/__init__.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/__init__.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/__init__.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -107,7 +107,6 @@
, content_types=contentClasses
, permission=AddPortalContent
, extra_constructors=contentConstructors
- , fti=Portal.factory_type_information
).initialize( context )
profile_registry.registerProfile('default',
@@ -126,8 +125,7 @@
context.registerClass( Portal.CMFSite
, constructors=(factory.addConfiguredSiteForm,
- factory.addConfiguredSite,
- Portal.manage_addCMFSite)
+ factory.addConfiguredSite)
, icon='images/portal.gif'
)
Modified: CMF/branches/tseaver-viewification/CMFDefault/configure.zcml
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/configure.zcml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/configure.zcml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -12,10 +12,6 @@
package=".browser"
/>
- <include
- file="exportimport.zcml"
- />
-
<!-- XXX: Setting this is required to make the views accessible TTW, but it
breaks tests for now. 2005/10/21, TS
<five:traversable
Deleted: CMF/branches/tseaver-viewification/CMFDefault/exportimport.zcml
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/exportimport.zcml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/exportimport.zcml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,38 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:five="http://namespaces.zope.org/five"
- i18n_domain="cmf"
- >
-
- <five:implements
- class=".Portal.CMFSite"
- interface="Products.CMFCore.interfaces.ISiteRoot"
- />
-
- <five:implements
- class=".Document.Document"
- interface="Products.CMFCore.interfaces.IDAVAware"
- />
-
- <five:implements
- class=".File.File"
- interface="Products.CMFCore.interfaces.IDAVAware"
- />
-
- <five:implements
- class=".Image.Image"
- interface="Products.CMFCore.interfaces.IDAVAware"
- />
-
- <five:implements
- class=".Link.Link"
- interface="Products.CMFCore.interfaces.IDAVAware"
- />
-
- <five:implements
- class=".NewsItem.NewsItem"
- interface="Products.CMFCore.interfaces.IDAVAware"
- />
-
-</configure>
-
Modified: CMF/branches/tseaver-viewification/CMFDefault/profiles/default/cachingpolicymgr.xml
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/profiles/default/cachingpolicymgr.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/profiles/default/cachingpolicymgr.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
-<caching-policies>
+<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager">
<!-- TODO: add some sensible defaults -->
-</caching-policies>
+</object>
Modified: CMF/branches/tseaver-viewification/CMFDefault/profiles/default/contenttyperegistry.xml
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/profiles/default/contenttyperegistry.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/profiles/default/contenttyperegistry.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,28 +1,24 @@
<?xml version="1.0"?>
-<content-type-registry>
- <predicate predicate_id="link" predicate_type="extension"
- content_type_name="Link">
+<object name="content_type_registry" meta_type="Content Type Registry">
+ <predicate name="link" content_type_name="Link" predicate_type="extension">
<argument value="url,link"/>
</predicate>
- <predicate predicate_id="news" predicate_type="extension"
- content_type_name="News Item">
+ <predicate name="news" content_type_name="News Item"
+ predicate_type="extension">
<argument value="news"/>
</predicate>
- <predicate predicate_id="document"
- predicate_type="major_minor"
- content_type_name="Document">
+ <predicate name="document" content_type_name="Document"
+ predicate_type="major_minor">
<argument value="text"/>
<argument value=""/>
</predicate>
- <predicate predicate_id="image"
- predicate_type="major_minor"
- content_type_name="Image">
+ <predicate name="image" content_type_name="Image"
+ predicate_type="major_minor">
<argument value="image"/>
<argument value=""/>
</predicate>
- <predicate predicate_id="file" predicate_type="major_minor"
- content_type_name="File">
+ <predicate name="file" content_type_name="File" predicate_type="major_minor">
<argument value="application"/>
<argument value=""/>
</predicate>
-</content-type-registry>
+</object>
Modified: CMF/branches/tseaver-viewification/CMFDefault/profiles/default/properties.xml
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/profiles/default/properties.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/profiles/default/properties.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,10 +1,12 @@
<?xml version="1.0"?>
<site>
- <property name="title">Portal</property>
- <property name="description"></property>
- <property name="email_from_address" type="string">postmaster at localhost</property>
- <property name="email_from_name" type="string">Portal Administrator</property>
- <property name="validate_email" type="boolean">False</property>
- <property name="default_charset" type="string"></property>
- <property name="enable_permalink" type="boolean">False</property>
+ <property name="title">Portal</property>
+ <property name="description"></property>
+ <property name="email_from_address"
+ type="string">postmaster at localhost</property>
+ <property name="email_from_name"
+ type="string">Portal Administrator</property>
+ <property name="validate_email" type="boolean">False</property>
+ <property name="default_charset" type="string"></property>
+ <property name="enable_permalink" type="boolean">False</property>
</site>
Modified: CMF/branches/tseaver-viewification/CMFDefault/setuphandlers.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/setuphandlers.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/setuphandlers.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -18,11 +18,10 @@
from Products.CMFCore.utils import getToolByName
from exceptions import BadRequest
-from Portal import PortalGenerator
def importVarious(context):
- """ Import various settings from PortalGenerator.
+ """ Import various settings.
This provisional handler will be removed again as soon as full handlers
are implemented for these steps.
@@ -36,8 +35,9 @@
except BadRequest:
return 'Various settings: Nothing to import.'
- gen = PortalGenerator()
- gen.setupUserFolder(site)
- gen.setupMembersFolder(site)
+ site.manage_addProduct['OFSP'].manage_addUserFolder()
+ site.manage_addPortalFolder('Members')
+ site.Members.manage_addProduct['OFSP'].manage_addDTMLMethod('index_html',
+ 'Member list', '<dtml-return roster>')
return 'Various settings from PortalGenerator imported.'
Copied: CMF/branches/tseaver-viewification/CMFDefault/tests/common.py (from rev 40248, CMF/trunk/CMFDefault/tests/common.py)
Modified: CMF/branches/tseaver-viewification/CMFDefault/tests/test_DiscussionReply.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_DiscussionReply.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_DiscussionReply.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -24,8 +24,8 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.tests.base.testcase import RequestTest
Modified: CMF/branches/tseaver-viewification/CMFDefault/tests/test_Document.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_Document.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_Document.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,10 +15,8 @@
$Id$
"""
-from unittest import TestSuite, makeSuite, main
+import unittest
import Testing
-import Zope2
-Zope2.startup()
from os.path import abspath
from os.path import dirname
@@ -42,71 +40,43 @@
from Products.CMFCore.tests.base.content import STX_NO_HEADERS_BUT_COLON
from Products.CMFCore.tests.base.content import STX_WITH_HTML
from Products.CMFCore.tests.base.dummy import DummySite
-from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFCore.tests.base.tidata import FTIDATA_CMF15
from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
from Products.CMFCore.TypesTool import TypesTool
from Products.CMFDefault import utils
+from common import ConformsToContent
+
class RequestTestBase(RequestTest):
- def setUp(self):
- RequestTest.setUp(self)
- self.site = DummySite('site').__of__(self.root)
- self.site._setObject( 'portal_membership', DummyTool() )
-
- def _makeOne(self, id, *args, **kw):
+ def _getTargetClass(self):
from Products.CMFDefault.Document import Document
- return self.site._setObject( id, Document(id, *args, **kw) )
+ return Document
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
-class DocumentTests(RequestTestBase):
+class DocumentTests(ConformsToContent, RequestTestBase):
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
- from Products.CMFCore.interfaces.Contentish \
- import Contentish as IContentish
- from Products.CMFCore.interfaces.DublinCore \
- import CatalogableDublinCore as ICatalogableDublinCore
- from Products.CMFCore.interfaces.DublinCore \
- import DublinCore as IDublinCore
- from Products.CMFCore.interfaces.DublinCore \
- import MutableDublinCore as IMutableDublinCore
- from Products.CMFCore.interfaces.Dynamic \
- import DynamicType as IDynamicType
- from Products.CMFDefault.Document import Document
from Products.CMFDefault.interfaces.Document import IDocument
from Products.CMFDefault.interfaces.Document import IMutableDocument
- verifyClass(ICatalogableDublinCore, Document)
- verifyClass(IContentish, Document)
- verifyClass(IDocument, Document)
- verifyClass(IDublinCore, Document)
- verifyClass(IDynamicType, Document)
- verifyClass(IMutableDocument, Document)
- verifyClass(IMutableDublinCore, Document)
+ verifyClass(IDocument, self._getTargetClass())
+ verifyClass(IMutableDocument, self._getTargetClass())
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
- from Products.CMFCore.interfaces import ICatalogableDublinCore
- from Products.CMFCore.interfaces import IContentish
- from Products.CMFCore.interfaces import IDublinCore
- from Products.CMFCore.interfaces import IDynamicType
- from Products.CMFCore.interfaces import IMutableDublinCore
- from Products.CMFDefault.Document import Document
from Products.CMFDefault.interfaces import IDocument
from Products.CMFDefault.interfaces import IMutableDocument
- verifyClass(ICatalogableDublinCore, Document)
- verifyClass(IContentish, Document)
- verifyClass(IDocument, Document)
- verifyClass(IDublinCore, Document)
- verifyClass(IDynamicType, Document)
- verifyClass(IMutableDocument, Document)
- verifyClass(IMutableDublinCore, Document)
+ verifyClass(IDocument, self._getTargetClass())
+ verifyClass(IMutableDocument, self._getTargetClass())
def test_Empty(self):
d = self._makeOne('foo', text_format='structured-text')
@@ -405,6 +375,10 @@
class DocumentFTPGetTests(RequestTestBase):
+ def setUp(self):
+ RequestTest.setUp(self)
+ self.site = DummySite('site').__of__(self.root)
+
def testHTML( self ):
self.REQUEST['BODY']=BASIC_HTML
@@ -499,14 +473,8 @@
self.failUnless( header in get_headers )
-class DocumentPUTTests(RequestTest):
+class DocumentPUTTests(RequestTestBase):
- def _makeOne(self, id, *args, **kw):
- from Products.CMFDefault.Document import Document
-
- # NullResource.PUT calls the PUT method on the bare object!
- return Document(id, *args, **kw)
-
def test_PUTBasicHTML(self):
self.REQUEST['BODY'] = BASIC_HTML
d = self._makeOne('foo')
@@ -588,11 +556,11 @@
def test_suite():
- return TestSuite((
- makeSuite(DocumentTests),
- makeSuite(DocumentFTPGetTests),
- makeSuite(DocumentPUTTests),
+ return unittest.TestSuite((
+ unittest.makeSuite(DocumentTests),
+ unittest.makeSuite(DocumentFTPGetTests),
+ unittest.makeSuite(DocumentPUTTests),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
Modified: CMF/branches/tseaver-viewification/CMFDefault/tests/test_Favorite.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_Favorite.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_Favorite.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,29 +15,33 @@
$Id$
"""
-from unittest import TestCase, TestSuite, makeSuite, main
+import unittest
import Testing
-import Zope2
-Zope2.startup()
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
-from Products.CMFDefault.Favorite import Favorite
+from common import ConformsToContent
-class FavoriteTests( TestCase ):
- def setUp( self ):
+class FavoriteTests(ConformsToContent, unittest.TestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFDefault.Favorite import Favorite
+
+ return Favorite
+
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
+
+ def setUp(self):
self.site = DummySite('site')
self.site._setObject( 'portal_membership', DummyTool() )
self.site._setObject( 'portal_url', DummyTool() )
- def _makeOne(self, id, *args, **kw):
- return self.site._setObject( id, Favorite(id, *args, **kw) )
-
def test_Empty( self ):
utool = self.site.portal_url
- f = self._makeOne( 'foo' )
+ f = self.site._setObject('foo', self._makeOne('foo'))
self.assertEqual( f.getId(), 'foo' )
self.assertEqual( f.Title(), '' )
@@ -57,7 +61,8 @@
, description='Description'
).Description(), 'Description' )
- baz = self._makeOne( 'baz', remote_url='portal_url' )
+ baz = self.site._setObject('foo',
+ self._makeOne('baz', remote_url='portal_url'))
self.assertEqual( baz.getObject(), utool )
self.assertEqual( baz.getRemoteUrl()
, '%s/portal_url' % utool.root )
@@ -65,7 +70,7 @@
def test_edit( self ):
utool = self.site.portal_url
- f = self._makeOne( 'foo' )
+ f = self.site._setObject('foo', self._makeOne('foo'))
f.edit( 'portal_url' )
self.assertEqual( f.getObject(), utool )
self.assertEqual( f.getRemoteUrl()
@@ -74,7 +79,7 @@
def test_editEmpty( self ):
utool = self.site.portal_url
- f = self._makeOne( 'gnnn' )
+ f = self.site._setObject('gnnn', self._makeOne('gnnn'))
f.edit( '' )
self.assertEqual( f.getObject(), self.site )
self.assertEqual( f.getRemoteUrl(), utool.root )
@@ -82,9 +87,9 @@
def test_suite():
- return TestSuite((
- makeSuite( FavoriteTests ),
+ return unittest.TestSuite((
+ unittest.makeSuite(FavoriteTests),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
Copied: CMF/branches/tseaver-viewification/CMFDefault/tests/test_File.py (from rev 40248, CMF/trunk/CMFDefault/tests/test_File.py)
Modified: CMF/branches/tseaver-viewification/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_Image.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_Image.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,10 +15,8 @@
$Id$
"""
-from unittest import TestCase, TestSuite, makeSuite, main
+import unittest
import Testing
-import Zope2
-Zope2.startup()
from os.path import join as path_join
from cStringIO import StringIO
@@ -29,28 +27,36 @@
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.User import UnrestrictedUser
from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFDefault import tests
-from Products.CMFDefault.File import File
-from Products.CMFDefault.Image import Image
+from common import ConformsToContent
+
TESTS_HOME = tests.__path__[0]
TEST_JPG = path_join(TESTS_HOME, 'TestImage.jpg')
-class TestImageElement(TestCase):
+class TestImageElement(ConformsToContent, unittest.TestCase):
+ def _getTargetClass(self):
+ from Products.CMFDefault.Image import Image
+
+ return Image
+
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
+
def setUp(self):
self.site = DummySite('site')
self.site._setObject( 'portal_membership', DummyTool() )
def test_EditWithEmptyFile(self):
# Test handling of empty file uploads
- image = self.site._setObject( 'testimage', Image('testimage') )
+ image = self.site._setObject('testimage', self._makeOne('testimage'))
testfile = open(TEST_JPG, 'rb')
image.edit(file=testfile)
@@ -66,18 +72,9 @@
assert image.get_size() > 0
assert image.get_size() == testfilesize
- def test_File_setFormat(self):
- # Setting the DC.format must also set the content_type property
- file = File('testfile', format='image/jpeg')
- self.assertEqual(file.Format(), 'image/jpeg')
- self.assertEqual(file.content_type, 'image/jpeg')
- file.setFormat('image/gif')
- self.assertEqual(file.Format(), 'image/gif')
- self.assertEqual(file.content_type, 'image/gif')
-
def test_Image_setFormat(self):
# Setting the DC.format must also set the content_type property
- image = Image('testimage', format='image/jpeg')
+ image = self._makeOne('testimage', format='image/jpeg')
self.assertEqual(image.Format(), 'image/jpeg')
self.assertEqual(image.content_type, 'image/jpeg')
image.setFormat('image/gif')
@@ -88,24 +85,12 @@
# Test the content type after calling the constructor with the
# file object being passed in (http://www.zope.org/Collectors/CMF/370)
testfile = open(TEST_JPG, 'rb')
- image = Image('testimage', file=testfile)
+ image = self._makeOne('testimage', file=testfile)
testfile.close()
self.assertEqual(image.Format(), 'image/jpeg')
self.assertEqual(image.content_type, 'image/jpeg')
- def test_FileContentTypeUponConstruction(self):
- # Test the content type after calling the constructor with the
- # file object being passed in (http://www.zope.org/Collectors/CMF/370)
- testfile = open(TEST_JPG, 'rb')
- # Notice the cheat? File objects lack the extra intelligence that
- # picks content types from the actual file data, so it needs to be
- # helped along with a file extension...
- file = File('testfile.jpg', file=testfile)
- testfile.close()
- self.assertEqual(file.Format(), 'image/jpeg')
- self.assertEqual(file.content_type, 'image/jpeg')
-
class TestImageCopyPaste(PlacelessSetup, RequestTest):
# Tests related to http://www.zope.org/Collectors/CMF/176
@@ -129,7 +114,7 @@
self.site.invokeFactory('Folder', id='subfolder')
self.subfolder = self.site.subfolder
self.workflow = self.site.portal_workflow
- transaction.commit(1) # Make sure we have _p_jars
+ transaction.savepoint(optimistic=True) # Make sure we have _p_jars
except:
self.tearDown()
raise
@@ -193,11 +178,10 @@
def test_suite():
- return TestSuite((
- makeSuite(TestImageElement),
- makeSuite(TestImageCopyPaste),
+ return unittest.TestSuite((
+ unittest.makeSuite(TestImageElement),
+ unittest.makeSuite(TestImageCopyPaste),
))
- return suite
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
Modified: CMF/branches/tseaver-viewification/CMFDefault/tests/test_Link.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_Link.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_Link.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -14,29 +14,28 @@
$Id$
"""
-from unittest import TestCase, TestSuite, makeSuite, main
+
+import unittest
import Testing
-import Zope2
-Zope2.startup()
from re import compile
from Products.CMFCore.tests.base.content import BASIC_RFC822
from Products.CMFCore.tests.base.content import RFC822_W_CONTINUATION
-from Products.CMFCore.tests.base.dummy import DummySite
-from Products.CMFCore.tests.base.dummy import DummyTool
-from Products.CMFDefault.Link import Link
+from common import ConformsToContent
-class LinkTests(TestCase):
- def setUp(self):
- self.site = DummySite('site')
- mtool = self.site._setObject( 'portal_membership', DummyTool() )
+class LinkTests(ConformsToContent, unittest.TestCase):
- def _makeOne(self, id, *args, **kw):
- return self.site._setObject( id, Link(id, *args, **kw) )
+ def _getTargetClass(self):
+ from Products.CMFDefault.Link import Link
+ return Link
+
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
+
def canonTest(self, table):
for orig, wanted in table.items():
# test with constructor
@@ -48,7 +47,7 @@
self.assertEqual(d.getRemoteUrl(), wanted)
def test_Empty( self ):
- d = Link( 'foo' )
+ d = self._makeOne('foo')
self.assertEqual( d.Title(), '' )
self.assertEqual( d.Description(), '' )
self.assertEqual( d.getRemoteUrl(), '' )
@@ -135,9 +134,9 @@
def test_suite():
- return TestSuite((
- makeSuite(LinkTests),
+ return unittest.TestSuite((
+ unittest.makeSuite(LinkTests),
))
if __name__ == '__main__':
- main(defaultTest='test_suite')
+ unittest.main(defaultTest='test_suite')
Modified: CMF/branches/tseaver-viewification/CMFDefault/tests/test_NewsItem.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_NewsItem.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_NewsItem.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -24,49 +24,19 @@
from Products.CMFCore.tests.base.content import ENTITY_IN_TITLE
from Products.CMFCore.tests.base.testcase import RequestTest
+from common import ConformsToContent
-class NewsItemTests(unittest.TestCase):
- def _makeOne(self, id, *args, **kw):
- from Products.CMFDefault.NewsItem import NewsItem
+class NewsItemTests(ConformsToContent, unittest.TestCase):
- return NewsItem(id, *args, **kw)
-
- def test_z2interfaces(self):
- from Interface.Verify import verifyClass
- from Products.CMFCore.interfaces.Contentish \
- import Contentish as IContentish
- from Products.CMFCore.interfaces.DublinCore \
- import CatalogableDublinCore as ICatalogableDublinCore
- from Products.CMFCore.interfaces.DublinCore \
- import DublinCore as IDublinCore
- from Products.CMFCore.interfaces.DublinCore \
- import MutableDublinCore as IMutableDublinCore
- from Products.CMFCore.interfaces.Dynamic \
- import DynamicType as IDynamicType
+ def _getTargetClass(self):
from Products.CMFDefault.NewsItem import NewsItem
- verifyClass(ICatalogableDublinCore, NewsItem)
- verifyClass(IContentish, NewsItem)
- verifyClass(IDublinCore, NewsItem)
- verifyClass(IDynamicType, NewsItem)
- verifyClass(IMutableDublinCore, NewsItem)
+ return NewsItem
- def test_z3interfaces(self):
- from zope.interface.verify import verifyClass
- from Products.CMFCore.interfaces import ICatalogableDublinCore
- from Products.CMFCore.interfaces import IContentish
- from Products.CMFCore.interfaces import IDublinCore
- from Products.CMFCore.interfaces import IDynamicType
- from Products.CMFCore.interfaces import IMutableDublinCore
- from Products.CMFDefault.NewsItem import NewsItem
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
- verifyClass(ICatalogableDublinCore, NewsItem)
- verifyClass(IContentish, NewsItem)
- verifyClass(IDublinCore, NewsItem)
- verifyClass(IDynamicType, NewsItem)
- verifyClass(IMutableDublinCore, NewsItem)
-
def test_Empty_html(self):
d = self._makeOne('empty', text_format='html')
@@ -104,12 +74,14 @@
class NewsItemPUTTests(RequestTest):
- def _makeOne(self, id, *args, **kw):
+ def _getTargetClass(self):
from Products.CMFDefault.NewsItem import NewsItem
- # NullResource.PUT calls the PUT method on the bare object!
- return NewsItem(id, *args, **kw)
+ return NewsItem
+ def _makeOne(self, *args, **kw):
+ return self._getTargetClass()(*args, **kw)
+
def test_Init(self):
self.REQUEST['BODY'] = BASIC_STRUCTUREDTEXT
d = self._makeOne('foo', text='')
Modified: CMF/branches/tseaver-viewification/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_Portal.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_Portal.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -23,8 +23,8 @@
import Products
from Acquisition import aq_base
from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
Deleted: CMF/branches/tseaver-viewification/CMFDefault/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,51 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFDefault tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite('Products.CMFDefault.tests',[
- 'test_DefaultWorkflow',
- 'test_Discussions',
- 'test_DiscussionTool',
- 'test_Document',
- 'test_DublinCore',
- 'test_Favorite',
- 'test_Image',
- 'test_join',
- 'test_Link',
- 'test_MembershipTool',
- 'test_MetadataTool',
- 'test_NewsItem',
- 'test_Portal',
- 'test_PropertiesTool',
- 'test_RegistrationTool',
- 'test_utils',
- ])
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
Modified: CMF/branches/tseaver-viewification/CMFDefault/utils.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFDefault/utils.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFDefault/utils.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -24,12 +24,16 @@
from AccessControl import ModuleSecurityInfo
from Globals import package_home
-from zope.i18nmessageid import MessageIDFactory
from ZTUtils.Zope import complex_marshal
from exceptions import IllegalHTML
+try:
+ from zope.i18nmessageid import MessageFactory
+except ImportError: # BBB
+ from zope.i18nmessageid import MessageIDFactory as MessageFactory
+
security = ModuleSecurityInfo( 'Products.CMFDefault.utils' )
security.declarePrivate('_dtmldir')
@@ -429,4 +433,4 @@
return value
security.declarePublic('MessageID')
-MessageID = MessageIDFactory('cmf_default')
+MessageID = MessageFactory('cmf_default')
Copied: CMF/branches/tseaver-viewification/CMFSetup/Extensions (from rev 40248, CMF/trunk/CMFSetup/Extensions)
Modified: CMF/branches/tseaver-viewification/CMFSetup/cachingpolicymgr.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/cachingpolicymgr.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/cachingpolicymgr.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,50 +15,35 @@
$Id$
"""
-from AccessControl import ClassSecurityInfo
-from AccessControl.Permission import Permission
-from Globals import InitializeClass
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from xml.dom.minidom import parseString
from Products.CMFCore.utils import getToolByName
+from Products.GenericSetup.interfaces import INodeExporter
+from Products.GenericSetup.interfaces import INodeImporter
+from Products.GenericSetup.interfaces import PURGE, UPDATE
+from Products.GenericSetup.utils import PrettyDocument
-from permissions import ManagePortal
-from utils import CONVERTER
-from utils import DEFAULT
-from utils import ExportConfiguratorBase
-from utils import ImportConfiguratorBase
-from utils import KEY
-from utils import _xmldir
-
-#
-# Configurator entry points
-#
_FILENAME = 'cachingpolicymgr.xml'
+
def importCachingPolicyManager(context):
- """ Import cache policy maanger settings from an XML file.
+ """ Import caching policy manager settings from an XML file.
"""
site = context.getSite()
- cpm = getToolByName(site, 'caching_policy_manager', None)
- if cpm is None:
- return 'Cache policy manager: No tool!'
+ mode = context.shouldPurge() and PURGE or UPDATE
+ cptool = getToolByName(site, 'caching_policy_manager', None)
body = context.readDataFile(_FILENAME)
if body is None:
- return 'Cache policy manager: Nothing to import.'
+ return 'Caching policy manager: Nothing to import.'
- if context.shouldPurge():
- cpm.__init__()
+ importer = INodeImporter(cptool, None)
+ if importer is None:
+ return 'Caching policy manager: Import adapter misssing.'
- # now act on the settings we've retrieved
- configurator = CachingPolicyManagerImportConfigurator(site)
- cpm_info = configurator.parseXML(body)
+ importer.importNode(parseString(body).documentElement, mode=mode)
+ return 'Caching policy manager settings imported.'
- for policy in cpm_info['policies']:
- cpm.addPolicy(**policy)
-
- return 'Cache policy manager settings imported.'
-
def exportCachingPolicyManager(context):
""" Export caching policy manager settings as an XML file.
"""
@@ -68,79 +53,11 @@
if cptool is None:
return 'Caching policy manager: Nothing to export.'
- mhc = CachingPolicyManagerExportConfigurator( site ).__of__( site )
- text = mhc.generateXML()
+ exporter = INodeExporter(cptool)
+ if exporter is None:
+ return 'Caching policy manager: Export adapter misssing.'
- context.writeDataFile( _FILENAME, text, 'text/xml' )
-
+ doc = PrettyDocument()
+ doc.appendChild(exporter.exportNode(doc))
+ context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
return 'Caching policy manager settings exported.'
-
-
-class CachingPolicyManagerExportConfigurator(ExportConfiguratorBase):
- """ Synthesize XML description of cc properties.
- """
- security = ClassSecurityInfo()
-
- security.declareProtected( ManagePortal, 'listPolicyInfo' )
- def listPolicyInfo(self):
- """ Return a list of mappings describing the tool's policies.
- """
- cpm = getToolByName(self._site, 'caching_policy_manager')
- for policy_id, policy in cpm.listPolicies():
- yield {'policy_id': policy_id,
- 'predicate': policy.getPredicate(),
- 'mtime_func': policy.getMTimeFunc(),
- 'vary': policy.getVary(),
- 'etag_func': policy.getETagFunc(),
- 'max_age_secs': policy.getMaxAgeSecs(),
- 's_max_age_secs': policy.getSMaxAgeSecs(),
- 'pre_check': policy.getPreCheck(),
- 'post_check': policy.getPostCheck(),
- 'last_modified': bool(policy.getLastModified()),
- 'no_cache': bool(policy.getNoCache()),
- 'no_store': bool(policy.getNoStore()),
- 'must_revalidate': bool(policy.getMustRevalidate()),
- 'proxy_revalidate': bool(policy.getProxyRevalidate()),
- 'no_transform': bool(policy.getNoTransform()),
- 'public': bool(policy.getPublic()),
- 'private': bool(policy.getPrivate()),
- 'enable_304s': bool(policy.getEnable304s()),
- }
-
- security.declarePrivate('_getExportTemplate')
- def _getExportTemplate(self):
-
- return PageTemplateFile('cpmExport.xml', _xmldir)
-
-InitializeClass(CachingPolicyManagerExportConfigurator)
-
-class CachingPolicyManagerImportConfigurator(ImportConfiguratorBase):
-
- def _getImportMapping(self):
- return {
- 'caching-policies':
- { 'caching-policy': {KEY: 'policies', DEFAULT: ()} },
- 'caching-policy':
- { 'policy_id': {},
- 'remove': {},
- 'predicate': {},
- 'mtime_func': {},
- 'vary': {},
- 'etag_func': {},
- 'max_age_secs': {CONVERTER: self._convertToInteger},
- 's_max_age_secs': {CONVERTER: self._convertToInteger},
- 'pre_check': {CONVERTER: self._convertToInteger},
- 'post_check': {CONVERTER: self._convertToInteger},
- 'last_modified': {CONVERTER: self._convertToBoolean},
- 'no_cache': {CONVERTER: self._convertToBoolean},
- 'no_store': {CONVERTER: self._convertToBoolean},
- 'must_revalidate': {CONVERTER: self._convertToBoolean},
- 'proxy_revalidate': {CONVERTER: self._convertToBoolean},
- 'no_transform': {CONVERTER: self._convertToBoolean},
- 'public': {CONVERTER: self._convertToBoolean},
- 'private': {CONVERTER: self._convertToBoolean},
- 'enable_304s': {CONVERTER: self._convertToBoolean},
- },
- }
-
-InitializeClass(CachingPolicyManagerImportConfigurator)
Modified: CMF/branches/tseaver-viewification/CMFSetup/contenttyperegistry.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/contenttyperegistry.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/contenttyperegistry.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -15,123 +15,49 @@
$Id$
"""
-from AccessControl import ClassSecurityInfo
-from AccessControl.Permission import Permission
-from Globals import InitializeClass
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from xml.dom.minidom import parseString
from Products.CMFCore.utils import getToolByName
+from Products.GenericSetup.interfaces import INodeExporter
+from Products.GenericSetup.interfaces import INodeImporter
+from Products.GenericSetup.interfaces import PURGE, UPDATE
+from Products.GenericSetup.utils import PrettyDocument
-from permissions import ManagePortal
-from utils import CONVERTER
-from utils import DEFAULT
-from utils import ExportConfiguratorBase
-from utils import ImportConfiguratorBase
-from utils import KEY
-from utils import _xmldir
-
-#
-# Configurator entry points
-#
_FILENAME = 'contenttyperegistry.xml'
+
def importContentTypeRegistry(context):
""" Import content type registry settings from an XML file.
"""
site = context.getSite()
+ mode = context.shouldPurge() and PURGE or UPDATE
ctr = getToolByName(site, 'content_type_registry', None)
- if ctr is None:
- return 'Content type registry: No tool!'
body = context.readDataFile(_FILENAME)
if body is None:
return 'Content type registry: Nothing to import.'
- if context.shouldPurge():
- ctr.__init__()
+ importer = INodeImporter(ctr, None)
+ if importer is None:
+ return 'Content type registry: Import adapter misssing.'
- # now act on the settings we've retrieved
- configurator = ContentTypeRegistryImportConfigurator(site)
- cpm_info = configurator.parseXML(body)
-
- for info in cpm_info['predicates']:
- ctr.addPredicate(info['predicate_id'], info['predicate_type'])
- arguments = [x['value'].encode('ascii') for x in info['arguments']]
- ctr.getPredicate(info['predicate_id']).edit(*arguments)
- ctr.assignTypeName(info['predicate_id'], info['content_type_name'])
-
+ importer.importNode(parseString(body).documentElement, mode=mode)
return 'Content type registry settings imported.'
def exportContentTypeRegistry(context):
""" Export content type registry settings as an XML file.
"""
site = context.getSite()
- mhc = ContentTypeRegistryExportConfigurator( site ).__of__( site )
- text = mhc.generateXML()
- context.writeDataFile( _FILENAME, text, 'text/xml' )
+ ctr = getToolByName(site, 'content_type_registry', None)
+ if ctr is None:
+ return 'Content type registry: Nothing to export.'
- return 'Content type registry settings exported.'
+ exporter = INodeExporter(ctr)
+ if exporter is None:
+ return 'Content type registry: Export adapter misssing.'
-
-class ContentTypeRegistryExportConfigurator(ExportConfiguratorBase):
- """ Synthesize XML description of ctr properties.
- """
- security = ClassSecurityInfo()
-
- security.declareProtected( ManagePortal, 'listPredicateInfo' )
- def listPredicateInfo(self):
- """ Return a list of mappings describing the tool's predicates.
- """
- cpm = getToolByName(self._site, 'content_type_registry')
- for predicate_id, (predicate,
- content_type_name) in cpm.listPredicates():
- yield {'predicate_id': predicate_id,
- 'predicate_type': predicate.PREDICATE_TYPE,
- 'content_type_name' : content_type_name,
- 'arguments' : self._crackArgs(predicate),
- }
-
- _KNOWN_PREDICATE_TYPES = {
- 'major_minor': lambda x: (','.join(x.major), ','.join(x.minor)),
- 'extension': lambda x: (','.join(x.extensions),),
- 'mimetype_regex': lambda x: (x.pattern and x.pattern.pattern,),
- 'name_regex': lambda x: (x.pattern and x.pattern.pattern,),
- }
-
- security.declarePrivate('_crackArgs')
- def _crackArgs(self, predicate):
- """ Crack apart the "edit args" from predicate.
- """
- cracker = self._KNOWN_PREDICATE_TYPES.get(predicate.PREDICATE_TYPE)
- if cracker is not None:
- return cracker(predicate)
- return () # XXX: raise?
-
- security.declarePrivate('_getExportTemplate')
- def _getExportTemplate(self):
-
- return PageTemplateFile('ctrExport.xml', _xmldir)
-
-InitializeClass(ContentTypeRegistryExportConfigurator)
-
-class ContentTypeRegistryImportConfigurator(ImportConfiguratorBase):
-
- def _getImportMapping(self):
- return {
- 'content-type-registry':
- { 'predicate': {KEY: 'predicates', DEFAULT: ()}
- },
- 'predicate':
- { 'predicate_id': {},
- 'remove': {},
- 'predicate_type': {},
- 'content_type_name': {},
- 'argument': {KEY: 'arguments', DEFAULT: ()},
- },
- 'argument':
- { 'value': {},
- },
- }
-
-InitializeClass(ContentTypeRegistryImportConfigurator)
+ doc = PrettyDocument()
+ doc.appendChild(exporter.exportNode(doc))
+ context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
+ return 'Content type registry settings exported.'
Modified: CMF/branches/tseaver-viewification/CMFSetup/properties.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/properties.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/properties.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -10,88 +10,48 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Site properties setup handlers.
+"""Site properties setup handlers.
$Id$
"""
-from AccessControl import ClassSecurityInfo
-from Globals import InitializeClass
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from xml.dom.minidom import parseString
-from permissions import ManagePortal
-from utils import _xmldir
-from utils import ConfiguratorBase
-from utils import DEFAULT, KEY
+from Products.GenericSetup.interfaces import INodeExporter
+from Products.GenericSetup.interfaces import INodeImporter
+from Products.GenericSetup.interfaces import PURGE, UPDATE
+from Products.GenericSetup.utils import PrettyDocument
-
-#
-# Configurator entry points
-#
_FILENAME = 'properties.xml'
+
def importSiteProperties(context):
""" Import site properties from an XML file.
"""
site = context.getSite()
- encoding = context.getEncoding()
+ mode = context.shouldPurge() and PURGE or UPDATE
- if context.shouldPurge():
-
- for prop_map in site._propertyMap():
- prop_id = prop_map['id']
- if 'd' in prop_map.get('mode', 'wd') and \
- prop_id not in ('title', 'description'):
- site._delProperty(prop_id)
- else:
- if prop_map.get('type') == 'multiple selection':
- prop_value = ()
- else:
- prop_value = ''
- site._updateProperty(prop_id, prop_value)
-
- xml = context.readDataFile(_FILENAME)
- if xml is None:
+ body = context.readDataFile(_FILENAME)
+ if body is None:
return 'Site properties: Nothing to import.'
- spc = SitePropertiesConfigurator(site, encoding)
- site_info = spc.parseXML(xml)
+ importer = INodeImporter(site, None)
+ if importer is None:
+ return 'Site properties: Import adapter misssing.'
- for prop_info in site_info['properties']:
- spc.initProperty(site, prop_info)
-
+ importer.importNode(parseString(body).documentElement, mode=mode)
return 'Site properties imported.'
def exportSiteProperties(context):
""" Export site properties as an XML file.
"""
site = context.getSite()
- spc = SitePropertiesConfigurator(site).__of__(site)
- xml = spc.generateXML()
- context.writeDataFile(_FILENAME, xml, 'text/xml')
+ exporter = INodeExporter(site)
+ if exporter is None:
+ return 'Site properties: Export adapter misssing.'
+ doc = PrettyDocument()
+ doc.appendChild(exporter.exportNode(doc))
+ context.writeDataFile(_FILENAME, doc.toprettyxml(' '), 'text/xml')
return 'Site properties exported.'
-
-
-class SitePropertiesConfigurator(ConfiguratorBase):
- """ Synthesize XML description of site's properties.
- """
- security = ClassSecurityInfo()
-
- security.declareProtected(ManagePortal, 'listSiteInfos')
- def listSiteInfos(self):
- """ Get a sequence of mappings for site properties.
- """
- return tuple( [ self._extractProperty(self._site, prop_map)
- for prop_map in self._site._propertyMap() ] )
-
- def _getExportTemplate(self):
-
- return PageTemplateFile('spcExport.xml', _xmldir)
-
- def _getImportMapping(self):
-
- return { 'site': { 'property': {KEY: 'properties', DEFAULT: () } } }
-
-InitializeClass(SitePropertiesConfigurator)
Deleted: CMF/branches/tseaver-viewification/CMFSetup/tests/common.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/common.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/common.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,189 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFSetup product: unit test utilities.
-
-$Id$
-"""
-
-import os
-import shutil
-from tarfile import TarFile
-
-from Products.CMFCore.tests.base.testcase import SecurityRequestTest
-
-
-class DOMComparator:
-
- def _compareDOM( self, found_text, expected_text, debug=False ):
-
- found_lines = [ x.strip() for x in found_text.splitlines() ]
- found_text = '\n'.join( filter( None, found_lines ) )
-
- expected_lines = [ x.strip() for x in expected_text.splitlines() ]
- expected_text = '\n'.join( filter( None, expected_lines ) )
-
- from xml.dom.minidom import parseString
- found = parseString( found_text )
- expected = parseString( expected_text )
- fxml = found.toxml()
- exml = expected.toxml()
-
- if fxml != exml:
-
- if debug:
- zipped = zip( fxml, exml )
- diff = [ ( i, zipped[i][0], zipped[i][1] )
- for i in range( len( zipped ) )
- if zipped[i][0] != zipped[i][1]
- ]
- import pdb; pdb.set_trace()
-
- print 'Found:'
- print fxml
- print
- print 'Expected:'
- print exml
- print
-
- self.assertEqual( found.toxml(), expected.toxml() )
-
-class BaseRegistryTests( SecurityRequestTest, DOMComparator ):
-
- def _makeOne( self, *args, **kw ):
-
- # Derived classes must implement _getTargetClass
- return self._getTargetClass()( *args, **kw )
-
-def _clearTestDirectory( root_path ):
-
- if os.path.exists( root_path ):
- shutil.rmtree( root_path )
-
-def _makeTestFile( filename, root_path, contents ):
-
- path, filename = os.path.split( filename )
-
- subdir = os.path.join( root_path, path )
-
- if not os.path.exists( subdir ):
- os.makedirs( subdir )
-
- fqpath = os.path.join( subdir, filename )
-
- file = open( fqpath, 'wb' )
- file.write( contents )
- file.close()
- return fqpath
-
-class FilesystemTestBase( SecurityRequestTest ):
-
- def _makeOne( self, *args, **kw ):
-
- return self._getTargetClass()( *args, **kw )
-
- def setUp( self ):
-
- SecurityRequestTest.setUp( self )
- self._clearTempDir()
-
- def tearDown( self ):
-
- self._clearTempDir()
- SecurityRequestTest.tearDown( self )
-
- def _clearTempDir( self ):
-
- _clearTestDirectory( self._PROFILE_PATH )
-
- def _makeFile( self, filename, contents ):
-
- return _makeTestFile( filename, self._PROFILE_PATH, contents )
-
-
-class TarballTester( DOMComparator ):
-
- def _verifyTarballContents( self, fileish, toc_list, when=None ):
-
- fileish.seek( 0L )
- tarfile = TarFile.open( 'foo.tar.gz', fileobj=fileish, mode='r:gz' )
- items = tarfile.getnames()
- items.sort()
- toc_list.sort()
-
- self.assertEqual( len( items ), len( toc_list ) )
- for i in range( len( items ) ):
- self.assertEqual( items[ i ], toc_list[ i ] )
-
- if when is not None:
- for tarinfo in tarfile:
- self.failIf( tarinfo.mtime < when )
-
- def _verifyTarballEntry( self, fileish, entry_name, data ):
-
- fileish.seek( 0L )
- tarfile = TarFile.open( 'foo.tar.gz', fileobj=fileish, mode='r:gz' )
- extract = tarfile.extractfile( entry_name )
- found = extract.read()
- self.assertEqual( found, data )
-
- def _verifyTarballEntryXML( self, fileish, entry_name, data ):
-
- fileish.seek( 0L )
- tarfile = TarFile.open( 'foo.tar.gz', fileobj=fileish, mode='r:gz' )
- extract = tarfile.extractfile( entry_name )
- found = extract.read()
- self._compareDOM( found, data )
-
-
-class DummyExportContext:
-
- def __init__( self, site ):
- self._site = site
- self._wrote = []
-
- def getSite( self ):
- return self._site
-
- def writeDataFile( self, filename, text, content_type, subdir=None ):
- if subdir is not None:
- filename = '%s/%s' % ( subdir, filename )
- self._wrote.append( ( filename, text, content_type ) )
-
-class DummyImportContext:
-
- def __init__( self, site, purge=True, encoding=None ):
- self._site = site
- self._purge = purge
- self._encoding = encoding
- self._files = {}
-
- def getSite( self ):
- return self._site
-
- def getEncoding( self ):
- return self._encoding
-
- def readDataFile( self, filename, subdir=None ):
-
- if subdir is not None:
- filename = '/'.join( (subdir, filename) )
-
- return self._files.get( filename )
-
- def shouldPurge( self ):
-
- return self._purge
-
-def dummy_handler( context ):
-
- pass
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_actions.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_actions.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_actions.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -26,19 +26,18 @@
from OFS.Folder import Folder
from OFS.OrderedFolder import OrderedFolder
from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
from zope.interface import implements
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.interfaces.portal_actions \
import ActionProvider as IActionProvider
from Products.CMFCore.interfaces import IActionsTool
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
-
class DummyTool( OrderedFolder, ActionProviderBase ):
__implements__ = ( IActionProvider, )
@@ -124,7 +123,7 @@
PlacelessSetup.setUp(self)
BaseRegistryTests.setUp(self)
zcml.load_config('meta.zcml', Products.Five)
- zcml.load_config('configure.zcml', Products.CMFCore)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
def tearDown(self):
BaseRegistryTests.tearDown(self)
Deleted: CMF/branches/tseaver-viewification/CMFSetup/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,48 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFSetup tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite( 'Products.CMFSetup.tests'
- , [ 'test_actions'
- , 'test_context'
- , 'test_differ'
- , 'test_properties'
- , 'test_registry'
- , 'test_rolemap'
- , 'test_skins'
- , 'test_tool'
- , 'test_typeinfo'
- , 'test_utils'
- , 'test_workflow'
- ]
- )
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
-
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_cachingpolicymgr.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_cachingpolicymgr.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -14,16 +14,20 @@
$Id$
"""
+
import unittest
-#import Testing
+import Testing
+import Products
+from Products.Five import zcml
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-class _CachingPolicyManagerSetup(BaseRegistryTests):
+class _CachingPolicyManagerSetup(PlacelessSetup, BaseRegistryTests):
POLICY_ID = 'policy_id'
PREDICATE = "python:object.getId() == 'foo'"
@@ -37,44 +41,21 @@
_EMPTY_EXPORT = """\
<?xml version="1.0"?>
-<caching-policies>
-</caching-policies>
+<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager"/>
"""
_WITH_POLICY_EXPORT = """\
<?xml version="1.0"?>
-<caching-policies>
- <caching-policy
- policy_id="%s"
- predicate="%s"
- mtime_func="%s"
- vary="%s"
- etag_func="%s"
- max_age_secs="%d"
- s_max_age_secs="%d"
- pre_check="%d"
- post_check="%d"
- last_modified="False"
- no_cache="True"
- no_store="True"
- must_revalidate="True"
- proxy_revalidate="True"
- no_transform="True"
- public="True"
- private="True"
- enable_304s="True"
- />
-</caching-policies>
-""" % (POLICY_ID,
- PREDICATE,
- MTIME_FUNC,
- VARY,
- ETAG_FUNC,
- MAX_AGE_SECS,
- S_MAX_AGE_SECS,
- PRE_CHECK,
- POST_CHECK,
- )
+<object name="caching_policy_manager" meta_type="CMF Caching Policy Manager">
+ <caching-policy name="%s" enable_304s="True"
+ etag_func="%s" last_modified="False" max_age_secs="%d"
+ mtime_func="%s" must_revalidate="True" no_cache="True"
+ no_store="True" no_transform="True" post_check="%d" pre_check="%d"
+ predicate="%s" private="True"
+ proxy_revalidate="True" public="True" s_max_age_secs="%d" vary="%s"/>
+</object>
+""" % (POLICY_ID, ETAG_FUNC, MAX_AGE_SECS, MTIME_FUNC, POST_CHECK, PRE_CHECK,
+ PREDICATE, S_MAX_AGE_SECS, VARY)
def _initSite(self, with_policy=False):
from OFS.Folder import Folder
@@ -107,69 +88,17 @@
)
return site
-class CachingPolicyManagerExportConfiguratorTests(_CachingPolicyManagerSetup):
+ def setUp(self):
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
- def _getTargetClass(self):
- from Products.CMFSetup.cachingpolicymgr \
- import CachingPolicyManagerExportConfigurator
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
- return CachingPolicyManagerExportConfigurator
- def test_generateXML_empty(self):
- site = self._initSite(with_policy=False)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._EMPTY_EXPORT)
-
- def test_generateXML_with_policy(self):
- site = self._initSite(with_policy=True)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._WITH_POLICY_EXPORT)
-
-
-class CachingPolicyManagerImportConfiguratorTests(_CachingPolicyManagerSetup):
-
- def _getTargetClass(self):
- from Products.CMFSetup.cachingpolicymgr \
- import CachingPolicyManagerImportConfigurator
-
- return CachingPolicyManagerImportConfigurator
-
- def test_parseXML_empty(self):
- site = self._initSite(with_policy=False)
- configurator = self._makeOne(site)
- cpm_info = configurator.parseXML(self._EMPTY_EXPORT)
-
- self.assertEqual(len(cpm_info['policies']), 0)
-
- def test_parseXML_with_policy(self):
- site = self._initSite(with_policy=False)
- configurator = self._makeOne(site)
- cpm_info = configurator.parseXML(self._WITH_POLICY_EXPORT)
-
- self.assertEqual(len(cpm_info['policies']), 1)
-
- info = cpm_info['policies'][0]
- self.assertEqual(info['policy_id'], self.POLICY_ID)
- self.assertEqual(info['predicate'], self.PREDICATE)
- self.assertEqual(info['mtime_func'], self.MTIME_FUNC)
- self.assertEqual(info['vary'], self.VARY)
- self.assertEqual(info['etag_func'], self.ETAG_FUNC)
- self.assertEqual(info['max_age_secs'], self.MAX_AGE_SECS)
- self.assertEqual(info['s_max_age_secs'], self.S_MAX_AGE_SECS)
- self.assertEqual(info['pre_check'], self.PRE_CHECK)
- self.assertEqual(info['post_check'], self.POST_CHECK)
- self.assertEqual(info['last_modified'], False)
- self.assertEqual(info['no_cache'], True)
- self.assertEqual(info['no_store'], True)
- self.assertEqual(info['must_revalidate'], True)
- self.assertEqual(info['proxy_revalidate'], True)
- self.assertEqual(info['no_transform'], True)
- self.assertEqual(info['public'], True)
- self.assertEqual(info['private'], True)
- self.assertEqual(info['enable_304s'], True)
-
class Test_exportCachingPolicyManager(_CachingPolicyManagerSetup):
def test_empty(self):
@@ -240,8 +169,6 @@
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(CachingPolicyManagerExportConfiguratorTests),
- unittest.makeSuite(CachingPolicyManagerImportConfiguratorTests),
unittest.makeSuite(Test_exportCachingPolicyManager),
unittest.makeSuite(Test_importCachingPolicyManager),
))
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_catalog.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_catalog.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_catalog.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -25,15 +25,14 @@
from Products.ZCTextIndex.Lexicon import Splitter
from Products.ZCTextIndex.Lexicon import StopWordRemover
from Products.ZCTextIndex.ZCTextIndex import PLexicon
-from zope.app.tests.placelesssetup import PlacelessSetup
from Products.CMFCore.CatalogTool import CatalogTool
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
-
class _extra:
pass
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_contenttyperegistry.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_contenttyperegistry.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_contenttyperegistry.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -14,13 +14,17 @@
$Id$
"""
+
import unittest
-#import Testing
+import Testing
+import Products
+from Products.Five import zcml
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
_TEST_PREDICATES = (
('plain_text', 'major_minor', ('text', 'plain,javascript'), 'File'),
@@ -29,7 +33,7 @@
('logfiles', 'name_regex', ('error_log-.*',), 'Log File'),
)
-class _ContentTypeRegistrySetup(BaseRegistryTests):
+class _ContentTypeRegistrySetup(PlacelessSetup, BaseRegistryTests):
MAJOR_MINOR_ID = _TEST_PREDICATES[0][0]
MAJOR = _TEST_PREDICATES[0][2][0]
@@ -47,39 +51,30 @@
_EMPTY_EXPORT = """\
<?xml version="1.0"?>
-<content-type-registry>
-</content-type-registry>
+<object name="content_type_registry" meta_type="Content Type Registry"/>
"""
_WITH_POLICY_EXPORT = """\
<?xml version="1.0"?>
-<content-type-registry>
- <predicate
- predicate_id="%s"
- predicate_type="major_minor"
- content_type_name="%s">
- <argument value="%s" />
- <argument value="%s" />
+<object name="content_type_registry" meta_type="Content Type Registry">
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="major_minor">
+ <argument value="%s"/>
+ <argument value="%s"/>
</predicate>
- <predicate
- predicate_id="%s"
- predicate_type="extension"
- content_type_name="%s">
- <argument value="%s" />
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="extension">
+ <argument value="%s"/>
</predicate>
- <predicate
- predicate_id="%s"
- predicate_type="mimetype_regex"
- content_type_name="%s">
- <argument value="%s" />
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="mimetype_regex">
+ <argument value="%s"/>
</predicate>
- <predicate
- predicate_id="%s"
- predicate_type="name_regex"
- content_type_name="%s">
- <argument value="%s" />
+ <predicate name="%s" content_type_name="%s"
+ predicate_type="name_regex">
+ <argument value="%s"/>
</predicate>
-</content-type-registry>
+</object>
""" % (MAJOR_MINOR_ID,
MAJOR_MINOR_TYPENAME,
MAJOR,
@@ -114,84 +109,17 @@
return site
-class ContentTypeRegistryExportConfiguratorTests(_ContentTypeRegistrySetup):
+ def setUp(self):
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
- def _getTargetClass(self):
- from Products.CMFSetup.contenttyperegistry \
- import ContentTypeRegistryExportConfigurator
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
- return ContentTypeRegistryExportConfigurator
- def test_generateXML_empty(self):
- site = self._initSite(mit_predikat=False)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._EMPTY_EXPORT)
-
- def test_generateXML_with_policy(self):
- site = self._initSite(mit_predikat=True)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), self._WITH_POLICY_EXPORT)
-
-
-class ContentTypeRegistryImportConfiguratorTests(_ContentTypeRegistrySetup):
-
- def _getTargetClass(self):
- from Products.CMFSetup.contenttyperegistry \
- import ContentTypeRegistryImportConfigurator
-
- return ContentTypeRegistryImportConfigurator
-
- def test_parseXML_empty(self):
- site = self._initSite(mit_predikat=False)
- configurator = self._makeOne(site)
- ctr_info = configurator.parseXML(self._EMPTY_EXPORT)
-
- self.assertEqual(len(ctr_info['predicates']), 0)
-
- def test_parseXML_with_policy(self):
- site = self._initSite(mit_predikat=False)
- configurator = self._makeOne(site)
- ctr_info = configurator.parseXML(self._WITH_POLICY_EXPORT)
-
- self.assertEqual(len(ctr_info['predicates']), len(_TEST_PREDICATES))
-
- info = ctr_info['predicates'][0]
- self.assertEqual(info['predicate_id'], self.MAJOR_MINOR_ID)
- self.assertEqual(info['predicate_type'], 'major_minor')
- self.assertEqual(info['content_type_name'], self.MAJOR_MINOR_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 2)
- self.assertEqual(arguments[0]['value'], self.MAJOR)
- self.assertEqual(arguments[1]['value'], self.MINOR)
-
- info = ctr_info['predicates'][1]
- self.assertEqual(info['predicate_id'], self.EXTENSION_ID)
- self.assertEqual(info['predicate_type'], 'extension')
- self.assertEqual(info['content_type_name'], self.EXTENSION_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 1)
- self.assertEqual(arguments[0]['value'], self.EXTENSIONS)
-
- info = ctr_info['predicates'][2]
- self.assertEqual(info['predicate_id'], self.MIMETYPE_REGEX_ID)
- self.assertEqual(info['predicate_type'], 'mimetype_regex')
- self.assertEqual(info['content_type_name'],
- self.MIMETYPE_REGEX_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 1)
- self.assertEqual(arguments[0]['value'], self.MIMETYPE_REGEX)
-
- info = ctr_info['predicates'][3]
- self.assertEqual(info['predicate_id'], self.NAME_REGEX_ID)
- self.assertEqual(info['predicate_type'], 'name_regex')
- self.assertEqual(info['content_type_name'],
- self.NAME_REGEX_TYPENAME)
- arguments = info['arguments']
- self.assertEqual(len(arguments), 1)
- self.assertEqual(arguments[0]['value'], self.NAME_REGEX)
-
class Test_exportContentTypeRegistry(_ContentTypeRegistrySetup):
def test_empty(self):
@@ -267,12 +195,9 @@
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(ContentTypeRegistryExportConfiguratorTests),
- unittest.makeSuite(ContentTypeRegistryImportConfiguratorTests),
unittest.makeSuite(Test_exportContentTypeRegistry),
unittest.makeSuite(Test_importContentTypeRegistry),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
-
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_cookieauth.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_cookieauth.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_cookieauth.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -21,15 +21,14 @@
import Products
from OFS.Folder import Folder
from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
from Products.CMFCore.CookieCrumbler import CookieCrumbler
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
-
class _CookieCrumblerSetup(PlacelessSetup, BaseRegistryTests):
def _initSite(self, use_changed=False):
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_mailhost.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_mailhost.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_mailhost.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -22,11 +22,11 @@
from OFS.Folder import Folder
from Products.Five import zcml
from Products.MailHost.MailHost import MailHost
-from zope.app.tests.placelesssetup import PlacelessSetup
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
class _MailHostSetup(PlacelessSetup, BaseRegistryTests):
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_properties.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_properties.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_properties.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -14,46 +14,47 @@
$Id$
"""
+
import unittest
import Testing
-import Zope2
-Zope2.startup()
-from OFS.Folder import Folder
+import Products
+from Products.Five import zcml
+from Products.CMFCore.PortalObject import PortalObjectBase
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
_EMPTY_EXPORT = """\
-<?xml version="1.0"?>
+<?xml version="1.0" ?>
<site>
+ <property name="title"/>
</site>
"""
_NORMAL_EXPORT = """\
-<?xml version="1.0"?>
+<?xml version="1.0" ?>
<site>
- <property name="foo" type="string">Foo</property>
- <property name="bar" type="tokens">
- <element value="Bar"/></property>
- <property name="moo" type="tokens">
- <element value="Moo"/></property>
+ <property name="title"/>
+ <property name="foo" type="string">Foo</property>
+ <property name="bar" type="tokens">
+ <element value="Bar"/>
+ </property>
+ <property name="moo" type="tokens">
+ <element value="Moo"/>
+ </property>
</site>
"""
-class DummySite(Folder):
+class _SitePropertiesSetup(PlacelessSetup, BaseRegistryTests):
- _properties = ()
-
-
-class _SitePropertiesSetup(BaseRegistryTests):
-
def _initSite(self, foo=2, bar=2):
- self.root.site = DummySite()
+ self.root.site = PortalObjectBase('foo_site')
site = self.root.site
if foo > 0:
@@ -70,109 +71,40 @@
return site
+ def setUp(self):
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
-class SitePropertiesConfiguratorTests(_SitePropertiesSetup):
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
- def _getTargetClass(self):
- from Products.CMFSetup.properties import SitePropertiesConfigurator
- return SitePropertiesConfigurator
-
- def test_listSiteInfos_normal(self):
-
- site = self._initSite()
-
- EXPECTED = [ { 'id': 'foo',
- 'value': 'Foo',
- 'elements': (),
- 'type': 'string',
- 'select_variable': None },
- { 'id': 'bar',
- 'value': '',
- 'elements': ('Bar',),
- 'type': 'tokens',
- 'select_variable': None },
- { 'id': 'moo',
- 'value': '',
- 'elements': ('Moo',),
- 'type': 'tokens',
- 'select_variable': None } ]
-
- configurator = self._makeOne(site)
-
- site_info = configurator.listSiteInfos()
- self.assertEqual( len(site_info), len(EXPECTED) )
-
- for found, expected in zip(site_info, EXPECTED):
- self.assertEqual(found, expected)
-
- def test_generateXML_empty(self):
-
- site = self._initSite(0, 0)
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM(configurator.generateXML(), _EMPTY_EXPORT)
-
- def test_generateXML_normal(self):
-
- site = self._initSite()
- configurator = self._makeOne(site).__of__(site)
-
- self._compareDOM( configurator.generateXML(), _NORMAL_EXPORT )
-
- def test_parseXML_empty(self):
-
- site = self._initSite(0, 0)
- configurator = self._makeOne(site)
- site_info = configurator.parseXML(_EMPTY_EXPORT)
-
- self.assertEqual( len( site_info['properties'] ), 0 )
-
- def test_parseXML_normal(self):
-
- site = self._initSite()
- configurator = self._makeOne(site)
- site_info = configurator.parseXML(_NORMAL_EXPORT)
-
- self.assertEqual( len( site_info['properties'] ), 3 )
-
- info = site_info['properties'][0]
- self.assertEqual( info['id'], 'foo' )
- self.assertEqual( info['value'], 'Foo' )
- self.assertEqual( len( info['elements'] ), 0 )
-
- info = site_info['properties'][1]
- self.assertEqual( info['id'], 'bar' )
- self.assertEqual( info['value'], '' )
- self.assertEqual( len( info['elements'] ), 1 )
- self.assertEqual( info['elements'][0], 'Bar' )
-
-
class Test_exportSiteProperties(_SitePropertiesSetup):
def test_empty(self):
+ from Products.CMFSetup.properties import exportSiteProperties
site = self._initSite(0, 0)
context = DummyExportContext(site)
-
- from Products.CMFSetup.properties import exportSiteProperties
exportSiteProperties(context)
- self.assertEqual( len(context._wrote), 1 )
+ self.assertEqual(len(context._wrote), 1)
filename, text, content_type = context._wrote[0]
self.assertEqual(filename, 'properties.xml')
self._compareDOM(text, _EMPTY_EXPORT)
self.assertEqual(content_type, 'text/xml')
def test_normal(self):
+ from Products.CMFSetup.properties import exportSiteProperties
site = self._initSite()
context = DummyExportContext( site )
-
- from Products.CMFSetup.properties import exportSiteProperties
exportSiteProperties(context)
- self.assertEqual( len(context._wrote), 1 )
+ self.assertEqual(len(context._wrote), 1)
filename, text, content_type = context._wrote[0]
self.assertEqual(filename, 'properties.xml')
self._compareDOM(text, _NORMAL_EXPORT)
@@ -182,10 +114,11 @@
class Test_importSiteProperties(_SitePropertiesSetup):
def test_empty_default_purge(self):
+ from Products.CMFSetup.properties import importSiteProperties
site = self._initSite()
- self.assertEqual( len( site.propertyIds() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -193,17 +126,16 @@
context = DummyImportContext(site)
context._files['properties.xml'] = _EMPTY_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 0 )
+ self.assertEqual( len( site.propertyIds() ), 1 )
def test_empty_explicit_purge(self):
+ from Products.CMFSetup.properties import importSiteProperties
site = self._initSite()
- self.assertEqual( len( site.propertyIds() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -211,17 +143,16 @@
context = DummyImportContext(site, True)
context._files['properties.xml'] = _EMPTY_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 0 )
+ self.assertEqual( len( site.propertyIds() ), 1 )
def test_empty_skip_purge(self):
+ from Products.CMFSetup.properties import importSiteProperties
site = self._initSite()
- self.assertEqual( len( site.propertyIds() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
@@ -229,56 +160,34 @@
context = DummyImportContext(site, False)
context._files['properties.xml'] = _EMPTY_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
self.assertEqual( site.getProperty('bar'), ('Bar',) )
def test_normal(self):
+ from Products.CMFSetup.properties import importSiteProperties
site = self._initSite(0,0)
- self.assertEqual( len( site.propertyIds() ), 0 )
+ self.assertEqual( len( site.propertyIds() ), 1 )
context = DummyImportContext(site)
context._files['properties.xml'] = _NORMAL_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
importSiteProperties(context)
- self.assertEqual( len( site.propertyIds() ), 3 )
+ self.assertEqual( len( site.propertyIds() ), 4 )
self.failUnless( 'foo' in site.propertyIds() )
self.assertEqual( site.getProperty('foo'), 'Foo' )
self.failUnless( 'bar' in site.propertyIds() )
self.assertEqual( site.getProperty('bar'), ('Bar',) )
- def test_normal_encode_as_ascii(self):
- site = self._initSite(0,0)
-
- self.assertEqual( len( site.propertyIds() ), 0 )
-
- context = DummyImportContext(site, encoding='ascii')
- context._files['properties.xml'] = _NORMAL_EXPORT
-
- from Products.CMFSetup.properties import importSiteProperties
- importSiteProperties(context)
-
- self.assertEqual( len( site.propertyIds() ), 3 )
- self.failUnless( 'foo' in site.propertyIds() )
- self.assertEqual( site.getProperty('foo'), 'Foo' )
- self.failUnless( 'bar' in site.propertyIds() )
- self.assertEqual( site.getProperty('bar'), ('Bar',) )
-
-
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(SitePropertiesConfiguratorTests),
unittest.makeSuite(Test_exportSiteProperties),
unittest.makeSuite(Test_importSiteProperties),
))
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_skins.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_skins.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_skins.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -28,12 +28,11 @@
from Products.CMFCore import DirectoryView
from Products.CMFCore.utils import expandpath
from Products.CMFCore.utils import minimalpath
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DOMComparator
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-from common import BaseRegistryTests
-from common import DOMComparator
-from common import DummyExportContext
-from common import DummyImportContext
-
_TESTS_PATH = os.path.split( __file__ )[ 0 ]
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_typeinfo.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_typeinfo.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_typeinfo.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -23,20 +23,19 @@
import Products
from OFS.Folder import Folder
from Products.Five import zcml
-from zope.app.tests.placelesssetup import PlacelessSetup
from Products.CMFCore.permissions import View
from Products.CMFCore.permissions import AccessContentsInformation
from Products.CMFCore.permissions import ModifyPortalContent
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.TypesTool import FactoryTypeInformation
from Products.CMFCore.TypesTool import ScriptableTypeInformation
from Products.CMFCore.TypesTool import TypesTool
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
-
class _TypeInfoSetup(PlacelessSetup, BaseRegistryTests):
def _initSite(self, foo=0):
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_utils.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_utils.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_utils.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -23,7 +23,8 @@
from DateTime.DateTime import DateTime
from OFS.Folder import Folder
-from common import BaseRegistryTests
+from Products.CMFCore.tests.base.testcase import WarningInterceptor
+from Products.GenericSetup.tests.common import BaseRegistryTests
_NORMAL_PROPERTY_NODES = """\
@@ -166,6 +167,11 @@
</dummy>
"""
+_EMPTY_ATTR_IMPORT = """\
+<?xml version="1.0"?>
+<dummy title="">
+</dummy>
+"""
class DummyObject(Folder):
@@ -173,7 +179,7 @@
_properties = ()
-class _ConfiguratorBaseTests(BaseRegistryTests):
+class _ConfiguratorBaseTests(WarningInterceptor, BaseRegistryTests):
def _initSite(self, foo=2):
@@ -214,7 +220,15 @@
return site
+ def setUp(self):
+ BaseRegistryTests.setUp(self)
+ self._trap_warning_output()
+ def tearDown(self):
+ self._free_warning_output()
+ BaseRegistryTests.tearDown(self)
+
+
class ExportConfiguratorBaseTests(_ConfiguratorBaseTests):
def _getTargetClass(self):
@@ -292,7 +306,10 @@
return {
'dummy':
{ 'property': {KEY: 'properties', DEFAULT: ()},
- 'description': {CONVERTER: self._convertToUnique} } }
+ 'description': {CONVERTER: self._convertToUnique},
+ 'title': {},
+ '#text': {KEY: 'text'},
+ } }
return Configurator
@@ -395,10 +412,20 @@
self.fail('CMF Collector issue #352 (comment or empty '
'description bug): KeyError raised')
- self.assertEqual( len(site_info), 2 )
+ self.assertEqual( len(site_info), 3 )
self.assertEqual( site_info['description'], '' )
self.assertEqual( len(site_info['properties']), 0 )
+ self.assertEqual( site_info['text'], '' )
+ def test_parseXML_empty_with_encoding(self):
+ site = self._initSite()
+ configurator = self._makeOne(site, encoding='latin-1')
+ site_info = configurator.parseXML(_EMPTY_ATTR_IMPORT)
+ self.assertEqual(site_info['title'], '')
+ self.assertEqual(type(site_info['title']), str)
+ self.assertEqual(site_info['text'], '')
+ self.assertEqual(type(site_info['text']), str)
+
def test_initProperty_normal(self):
EXPECTED = _NORMAL_PROPERTY_INFO
Modified: CMF/branches/tseaver-viewification/CMFSetup/tests/test_workflow.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/tests/test_workflow.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/tests/test_workflow.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -22,16 +22,16 @@
from OFS.Folder import Folder
from Products.PythonScripts.PythonScript import PythonScript
+from Products.ExternalMethod.ExternalMethod import ExternalMethod
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
from Products.DCWorkflow.Transitions import TRIGGER_USER_ACTION
from Products.DCWorkflow.Transitions import TRIGGER_AUTOMATIC
+from Products.GenericSetup.tests.common import BaseRegistryTests
+from Products.GenericSetup.tests.common import DummyExportContext
+from Products.GenericSetup.tests.common import DummyImportContext
-from common import BaseRegistryTests
-from common import DummyExportContext
-from common import DummyImportContext
-
class DummyWorkflowTool( Folder ):
def __init__( self, id='portal_workflow' ):
@@ -219,6 +219,9 @@
script = PythonScript( k )
script.write( v[ 1 ] )
+ elif v[ 0 ] == ExternalMethod.meta_type:
+ script = ExternalMethod(k,'', v[3], v[4])
+
else:
raise ValueError, 'Unknown script type: %s' % v[ 0 ]
@@ -722,9 +725,13 @@
self.assertEqual( info[ 'meta_type' ], expected[ 0 ] )
self.assertEqual( info[ 'body' ], expected[ 1 ] )
- self.assertEqual( info[ 'filename' ]
- , expected[ 2 ] % WF_ID )
+ if info[ 'meta_type' ] == PythonScript.meta_type:
+ self.assertEqual( info[ 'filename' ]
+ , expected[ 2 ] % WF_ID )
+ else:
+ self.assertEqual( info[ 'filename' ], expected[ 2 ] )
+
def test_generateXML_empty( self ):
WF_ID = 'empty'
@@ -1246,8 +1253,11 @@
# Body is not kept as part of the workflow XML
- self.assertEqual( script[ 'filename' ]
- , expected[ 2 ] % workflow_id )
+ if script[ 'meta_type' ] == PythonScript.meta_type:
+ self.assertEqual( script[ 'filename' ]
+ , expected[ 2 ] % workflow_id )
+ else:
+ self.assertEqual( script[ 'filename' ], expected[ 2 ] )
_WF_PERMISSIONS = \
@@ -1379,11 +1389,11 @@
, 'Retire objects whose expiration is past.'
, 'expired'
, TRIGGER_AUTOMATIC
+ , 'before_expire'
, ''
, ''
, ''
, ''
- , ''
, { 'when_expired' : 'object/ZopeTime' }
, ()
, ()
@@ -1460,15 +1470,27 @@
{ 'before_open': ( PythonScript.meta_type
, _BEFORE_OPEN_SCRIPT
, 'workflows/%s/scripts/before_open.py'
+ , None
+ , None
)
, 'after_close': ( PythonScript.meta_type
, _AFTER_CLOSE_SCRIPT
, 'workflows/%s/scripts/after_close.py'
+ , None
+ , None
)
, 'after_kill': ( PythonScript.meta_type
, _AFTER_KILL_SCRIPT
, 'workflows/%s/scripts/after_kill.py'
+ , None
+ , None
)
+, 'before_expire': ( ExternalMethod.meta_type
+ , ''
+ , ''
+ , 'CMFSetup.test_method'
+ , 'test'
+ )
}
_EMPTY_TOOL_EXPORT = """\
@@ -1682,7 +1704,7 @@
title="Expire"
trigger="AUTOMATIC"
new_state="expired"
- before_script=""
+ before_script="before_expire"
after_script="">
<description>Retire objects whose expiration is past.</description>
<guard>
@@ -1795,16 +1817,29 @@
script_id="after_close"
type="Script (Python)"
filename="workflows/%(workflow_filename)s/after_close.py"
+ module=""
+ function=""
/>
<script
script_id="after_kill"
type="Script (Python)"
filename="workflows/%(workflow_filename)s/after_kill.py"
+ module=""
+ function=""
/>
<script
+ script_id="before_expire"
+ type="External Method"
+ filename=""
+ module="CMFSetup.test_method"
+ function="test"
+ />
+ <script
script_id="before_open"
type="Script (Python)"
filename="workflows/%(workflow_filename)s/before_open.py"
+ module=""
+ function=""
/>
</dc-workflow>
"""
@@ -1912,7 +1947,7 @@
title="Expire"
trigger="AUTOMATIC"
new_state="expired"
- before_script=""
+ before_script="before_expire"
after_script="">
<description>Retire objects whose expiration is past.</description>
<guard>
@@ -2025,16 +2060,29 @@
script_id="after_close"
type="Script (Python)"
filename="workflows/%(workflow_filename)s/scripts/after_close.py"
+ module=""
+ function=""
/>
<script
script_id="after_kill"
type="Script (Python)"
filename="workflows/%(workflow_filename)s/scripts/after_kill.py"
+ module=""
+ function=""
/>
<script
+ script_id="before_expire"
+ type="External Method"
+ filename=""
+ module="CMFSetup.test_method"
+ function="test"
+ />
+ <script
script_id="before_open"
type="Script (Python)"
filename="workflows/%(workflow_filename)s/scripts/before_open.py"
+ module=""
+ function=""
/>
</dc-workflow>
"""
@@ -2586,8 +2634,10 @@
expected = _WF_SCRIPTS[ script_id ]
self.assertEqual( script.meta_type, expected[ 0 ] )
- self.assertEqual( script.manage_FTPget(), expected[ 1 ] )
+ if script.meta_type == PythonScript.meta_type:
+ self.assertEqual( script.manage_FTPget(), expected[ 1 ] )
+
def test_from_empty_dcworkflow_workflow_scripts( self ):
WF_ID = 'dcworkflow_scripts'
@@ -2608,8 +2658,10 @@
expected = _WF_SCRIPTS[ script_id ]
self.assertEqual( script.meta_type, expected[ 0 ] )
- self.assertEqual( script.manage_FTPget(), expected[ 1 ] )
+ if script.meta_type == PythonScript.meta_type:
+ self.assertEqual( script.manage_FTPget(), expected[ 1 ] )
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite( WorkflowToolConfiguratorTests ),
Modified: CMF/branches/tseaver-viewification/CMFSetup/utils.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/utils.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/utils.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -16,6 +16,7 @@
"""
import os
+from warnings import warn
from xml.dom.minidom import parseString as domParseString
import Products
@@ -73,7 +74,8 @@
for name, val in node.attributes.items():
key = node_map[name].get( KEY, str(name) )
- val = self._encoding and val.encode(self._encoding) or val
+ if self._encoding is not None:
+ val = val.encode(self._encoding)
info[key] = val
for child in node.childNodes:
@@ -90,7 +92,8 @@
elif '#text' in node_map:
key = node_map['#text'].get(KEY, 'value')
val = child.nodeValue.lstrip()
- val = self._encoding and val.encode(self._encoding) or val
+ if self._encoding is not None:
+ val = val.encode(self._encoding)
info[key] = info.setdefault(key, '') + val
for k, v in node_map.items():
@@ -149,6 +152,9 @@
security.declareProtected(ManagePortal, 'initObject')
def initObject(self, parent, o_info):
+ warn('CMFSetup.utils including ImportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
obj_id = str(o_info['id'])
if obj_id not in parent.objectIds():
@@ -189,6 +195,9 @@
security.declareProtected(ManagePortal, 'initProperty')
def initProperty(self, obj, p_info):
+ warn('CMFSetup.utils including ImportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
prop_id = p_info['id']
prop_map = obj.propdict().get(prop_id, None)
@@ -250,6 +259,10 @@
def generateObjectNodes(self, obj_infos):
""" Pseudo API.
"""
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
+
lines = self._ob_nodes(objects=obj_infos).splitlines()
return '\n'.join(lines)
@@ -257,10 +270,17 @@
def generatePropertyNodes(self, prop_infos):
""" Pseudo API.
"""
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
+
lines = self._prop_nodes(properties=prop_infos).splitlines()
return '\n'.join(lines)
def _extractObject(self, obj):
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
properties = []
subobjects = []
@@ -285,6 +305,9 @@
'subobjects': tuple(subobjects) }
def _extractProperty(self, obj, prop_map):
+ warn('CMFSetup.utils including ExportConfiguratorBase is deprecated. '
+ 'Please use NodeAdapterBase from GenericSetup.utils instead.',
+ DeprecationWarning)
prop_id = prop_map['id']
prop = obj.getProperty(prop_id)
@@ -317,7 +340,7 @@
InitializeClass(ExportConfiguratorBase)
-# BBB: old class mixing the two, will be removed in CMF 1.7
+# BBB: old class mixing the two, will be removed in CMF 2.0
class ConfiguratorBase(ImportConfiguratorBase, ExportConfiguratorBase):
""" Synthesize XML description.
"""
@@ -361,7 +384,7 @@
value = _queryNodeAttribute( node, attr_name, _marker, encoding )
if value is _marker:
- raise ValueError, 'Invaid attribute: %s' % attr_name
+ raise ValueError, 'Invalid attribute: %s' % attr_name
return value
Modified: CMF/branches/tseaver-viewification/CMFSetup/workflow.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/workflow.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/workflow.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -196,9 +196,10 @@
, 'workflows/%s' % wf_dirname
)
for script_info in wf_scripts:
- context.writeDataFile(script_info['filename'],
- script_info['body'],
- 'text/plain')
+ if script_info['filename']:
+ context.writeDataFile(script_info['filename'],
+ script_info['body'],
+ 'text/plain')
return 'Workflows exported.'
@@ -365,7 +366,7 @@
security.declareProtected( ManagePortal, 'generateWorkflowScripts' )
def getWorkflowScripts( self, workflow_id ):
- """ Get workflow scripts inforation
+ """ Get workflow scripts information
"""
workflow_tool = getToolByName( self._site, 'portal_workflow' )
workflow = workflow_tool.getWorkflowById( workflow_id )
@@ -449,7 +450,7 @@
worklists tracked by the workflow (see '_extractWorklists').
'script_info' -- a list of mappings describing the scripts which
- provide added business logic (wee '_extractScripts').
+ provide added business logic (see '_extractScripts').
"""
workflow_info[ 'filename' ] = _getWorkflowFilename( workflow.getId() )
workflow_info[ 'state_variable' ] = workflow.state_var
@@ -789,10 +790,17 @@
'meta_type' -- the title of the worklist
- 'body' -- the text of the script
+ 'body' -- the text of the script (only applicable to scripts
+ of type Script (Python))
+ 'module' -- The module from where to load the function (only
+ applicable to External Method scripts)
+
+ 'function' -- The function to load from the 'module' given
+ (Only applicable to External Method scripts)
+
'filename' -- the name of the file to / from which the script
- is stored / loaded
+ is stored / loaded (Script (Python) only)
"""
result = []
@@ -802,10 +810,22 @@
for k, v in items:
filename = _getScriptFilename( workflow.getId(), k, v.meta_type )
+ body = ''
+ module = ''
+ function = ''
+ if v.meta_type == 'Script (Python)':
+ body = v.read()
+
+ if v.meta_type == 'External Method':
+ module = v.module()
+ function = v.function()
+
info = { 'id' : k
, 'meta_type' : v.meta_type
- , 'body' : v.read()
+ , 'body' : body
+ , 'module' : module
+ , 'function' : function
, 'filename' : filename
}
@@ -827,7 +847,11 @@
""" Return the name of the file which holds the script.
"""
wf_dir = workflow_id.replace( ' ', '_' )
- suffix = _METATYPE_SUFFIXES[ meta_type ]
+ suffix = _METATYPE_SUFFIXES.get(meta_type, None)
+
+ if suffix is None:
+ return ''
+
return 'workflows/%s/scripts/%s.%s' % ( wf_dir, script_id, suffix )
def _extractStateNodes( root, encoding=None ):
@@ -975,9 +999,20 @@
for s_node in root.getElementsByTagName( 'script' ):
+ try:
+ function = _getNodeAttribute( s_node, 'function' )
+ except ValueError:
+ function = ''
+ try:
+ module = _getNodeAttribute( s_node, 'module' )
+ except ValueError:
+ module = ''
+
info = { 'script_id' : _getNodeAttribute( s_node, 'script_id' )
, 'meta_type' : _getNodeAttribute( s_node, 'type' , encoding )
+ , 'function' : function
+ , 'module' : module
}
filename = _queryNodeAttribute( s_node, 'filename' , None, encoding )
@@ -1150,7 +1185,6 @@
_METATYPE_SUFFIXES = \
{ PythonScript.meta_type : 'py'
-, ExternalMethod.meta_type : 'em'
, DTMLMethod.meta_type : 'dtml'
}
@@ -1337,15 +1371,21 @@
id = str( s_info[ 'script_id' ] ) # no unicode!
meta_type = s_info[ 'meta_type' ]
filename = s_info[ 'filename' ]
+ file = ''
- file = context.readDataFile( filename )
+ if filename:
+ file = context.readDataFile( filename )
if meta_type == PythonScript.meta_type:
script = PythonScript( id )
script.write( file )
- #elif meta_type == ExternalMethod.meta_type:
- # script = ExternalMethod( id, title, module, function )
+ elif meta_type == ExternalMethod.meta_type:
+ script = ExternalMethod( id
+ , ''
+ , s_info['module']
+ , s_info['function']
+ )
elif meta_type == DTMLMethod.meta_type:
script = DTMLMethod( file, __name__=id )
Deleted: CMF/branches/tseaver-viewification/CMFSetup/xml/cpmExport.xml
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/xml/cpmExport.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/xml/cpmExport.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,43 +0,0 @@
-<?xml version="1.0"?>
-<caching-policies xmlns:tal="http://xml.zope.org/namespaces/tal">
- <caching-policy
- policy_id="POLICY_ID"
- predicate="PREDICATE"
- mtime_func="MTIME_FUNC"
- vary="VARY"
- etag_func="ETAG_FUNC"
- max_age_secs="MAX_AGE_SECS"
- s_max_age_secs="S_MAX_AGE_SECS"
- pre_check="PRE_CHECK"
- post_check="POST_CHECK"
- last_modified="LAST_MODIFIED"
- no_cache="NO_CACHE"
- no_store="NO_STORE"
- must_revalidate="MUST_REVALIDATE"
- proxy_revalidate="PROXY_REVALIDATE"
- no_transform="NO_TRANSFORM"
- public="PUBLIC"
- private="PRIVATE"
- enable_304s="ENABLE_304S"
- tal:repeat="info context/listPolicyInfo"
- tal:attributes="policy_id info/policy_id;
- predicate info/predicate;
- mtime_func info/mtime_func;
- vary info/vary;
- etag_func info/etag_func;
- max_age_secs info/max_age_secs;
- s_max_age_secs info/s_max_age_secs;
- pre_check info/pre_check;
- post_check info/post_check;
- last_modified info/last_modified;
- no_cache info/no_cache;
- no_store info/no_store;
- must_revalidate info/must_revalidate;
- proxy_revalidate info/proxy_revalidate;
- no_transform info/no_transform;
- public info/public;
- private info/private;
- enable_304s info/enable_304s;
- "
- />
-</caching-policies>
Deleted: CMF/branches/tseaver-viewification/CMFSetup/xml/ctrExport.xml
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/xml/ctrExport.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/xml/ctrExport.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,17 +0,0 @@
-<?xml version="1.0"?>
-<content-type-registry xmlns:tal="http://xml.zope.org/namespaces/tal">
- <predicate
- predicate_id="PREDICATE_ID"
- predicate_type="PREDICATE_TYPE"
- content_type_name="CONTENT_TYPE_NAME"
- tal:repeat="info context/listPredicateInfo"
- tal:attributes="predicate_id info/predicate_id;
- predicate_type info/predicate_type;
- content_type_name info/content_type_name; " >
- <argument
- value="ARGUMENT_VALUE"
- tal:repeat="arg info/arguments"
- tal:attributes="value arg"
- />
- </predicate>
-</content-type-registry>
Deleted: CMF/branches/tseaver-viewification/CMFSetup/xml/spcExport.xml
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/xml/spcExport.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/xml/spcExport.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<site xmlns:tal="http://xml.zope.org/namespaces/tal"
-><tal:span tal:define="prop_infos context/listSiteInfos"
- tal:replace="structure python: context.generatePropertyNodes(prop_infos)"/>
-</site>
Modified: CMF/branches/tseaver-viewification/CMFSetup/xml/wtcWorkflowExport.xml
===================================================================
--- CMF/branches/tseaver-viewification/CMFSetup/xml/wtcWorkflowExport.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFSetup/xml/wtcWorkflowExport.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -200,10 +200,14 @@
script_id="SCRIPT_ID"
type="Script (Python)"
filename="/path/to/SCRIPT_ID.py"
+ module=""
+ function=""
tal:repeat="script info/script_info"
tal:attributes="script_id script/id;
type script/meta_type;
filename script/filename;
+ module script/module;
+ function script/function
"
/>
</dc-workflow>
Deleted: CMF/branches/tseaver-viewification/CMFTopic/README.txt
===================================================================
--- CMF/branches/tseaver-viewification/CMFTopic/README.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFTopic/README.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,21 +0,0 @@
-Updating CMF Topic in a CMF Site
-
- Since default settings may change from time to time in CMF Topic,
- you may need to update your Topic types tool (and other) settings.
- This is done similarly to installing by adding an External Method
- to your CMF Site instance with the following configuration::
-
- **id** -- 'update_topic'
- **title** -- *Update Topic*
- **module name** -- 'CMFTopic.Update'
- **function name** -- 'update'
-
- Go to the management screen for the newly added external method and
- click the 'Try it' tab. The update function will execute and give
- information about the steps it took to register and update CMF Topic
- site information.
-
- *Note: This update script should **only** change values that are
- still at their default, such as changing an action from 'topic_edit'
- to 'topic_edit_form'. If you changed that action to 'mytopic_edit',
- the script should pass that by and not change your settings.*
Modified: CMF/branches/tseaver-viewification/CMFTopic/Topic.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFTopic/Topic.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFTopic/Topic.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -22,65 +22,12 @@
from Products.CMFDefault.SkinnedFolder import SkinnedFolder
from Products.CMFCore.utils import getToolByName
-from permissions import ListFolderContents
from permissions import View
from permissions import AddTopics
from permissions import ChangeTopics
-# Factory type information -- makes Topic objects play nicely
-# with the Types Tool (portal_types )
-factory_type_information = (
- { 'id' : 'Topic'
- , 'icon' : 'topic_icon.gif'
- , 'meta_type' : 'Portal Topic'
- , 'description' : 'Topics are canned queries for organizing content '
- 'with up to date queries into the catalog.'
- , 'product' : 'CMFTopic'
- , 'factory' : 'addTopic'
- , 'immediate_view' : 'topic_edit_form'
- , 'allowed_content_types': ('Topic',)
- , 'aliases' : {'(Default)': 'topic_view',
- 'view': 'topic_view'}
- , 'actions' : ( { 'id' : 'view'
- , 'name' : 'View'
- , 'action': 'string:${object_url}/topic_view'
- , 'permissions' : (View,)
- }
- , { 'id' : 'edit'
- , 'name' : 'Edit'
- , 'action': 'string:${object_url}/topic_edit_form'
- , 'permissions' : (ChangeTopics,)
- }
- , { 'id' : 'criteria'
- , 'name' : 'Criteria'
- , 'action': 'string:${object_url}/topic_criteria_form'
- , 'permissions' : (ChangeTopics,)
- }
- , { 'id' : 'folderContents'
- , 'name' : 'Subtopics'
- , 'action': 'string:${object_url}/folder_contents'
- , 'permissions' : (ListFolderContents,)
- }
- , { 'id' : 'new'
- , 'name' : 'New...'
- , 'action': 'string:${object_url}/folder_factories'
- , 'permissions' : (AddTopics,)
- , 'visible' : 0
- }
- , { 'id' : 'rename_items'
- , 'name' : 'Rename items'
- , 'action': 'string:${object_url}/folder_rename_form'
- , 'permissions' : (AddTopics,)
- , 'visible' : 0
- }
- )
- }
-,
-)
-
def addTopic( self, id, title='', REQUEST=None ):
-
""" Create an empty topic.
"""
topic = Topic( id )
@@ -92,7 +39,7 @@
REQUEST['RESPONSE'].redirect( 'manage_main' )
-class Topic( SkinnedFolder ):
+class Topic(SkinnedFolder):
""" Topics are 'canned queries'
@@ -287,4 +234,4 @@
"""
return "%s %s" % (self.title, self.description)
-InitializeClass( Topic )
+InitializeClass(Topic)
Modified: CMF/branches/tseaver-viewification/CMFTopic/__init__.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFTopic/__init__.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFTopic/__init__.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -57,7 +57,6 @@
, content_types = (Topic.Topic,)
, permission = AddTopics
, extra_constructors = (Topic.addTopic,)
- , fti = Topic.factory_type_information
).initialize( context )
profile_registry.registerProfile('default',
Modified: CMF/branches/tseaver-viewification/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFTopic/tests/test_DateC.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFTopic/tests/test_DateC.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -20,8 +20,9 @@
import Zope2
Zope2.startup()
+import Products
from DateTime.DateTime import DateTime
-
+from Products.CMFCore.tests.base.testcase import PlacelessSetup
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFTopic.Topic import Topic
@@ -149,7 +150,7 @@
self.assertEqual( expect_now.Date(), DateTime().Date() )
self.assertEqual( result[0][1]['range'], 'min:max' )
-class FriendlyDateCriterionFunctionalTests(RequestTest):
+class FriendlyDateCriterionFunctionalTests(PlacelessSetup, RequestTest):
# Test the date criterion using a "real CMF" with catalog etc.
selectable_diffs = [0, 1, 2, 5, 7, 14, 31, 93, 186, 365, 730]
nonzero_diffs = [1, 2, 5, 7, 14, 31, 93, 186, 365, 730]
@@ -157,7 +158,16 @@
day_diffs.extend(selectable_diffs)
def setUp(self):
+ import Products.CMFCore
+ import Products.Five
+ from Products.Five import zcml
+ import Products.GenericSetup
+ PlacelessSetup.setUp(self)
RequestTest.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.GenericSetup)
+ zcml.load_config('configure.zcml', Products.CMFCore)
+
factory = self.root.manage_addProduct['CMFDefault'].addConfiguredSite
factory('site', 'CMFDefault:default', snapshot=False)
self.site = self.root.site
@@ -179,6 +189,9 @@
dummy_ob.modified_date = self.now + i
dummy_ob.reindexObject()
+ def tearDown(self):
+ RequestTest.tearDown(self)
+ PlacelessSetup.tearDown(self)
def test_Harness(self):
# Make sure the test harness is set up OK
Modified: CMF/branches/tseaver-viewification/CMFTopic/tests/test_Topic.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFTopic/tests/test_Topic.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFTopic/tests/test_Topic.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -26,7 +26,6 @@
from Products.CMFCore.tests.base.testcase import SecurityTest
from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
from Products.CMFCore.TypesTool import TypesTool
-from Products.CMFTopic.Topic import factory_type_information as FTIDATA_TOPIC
class FauxBrain( Implicit ):
@@ -198,8 +197,8 @@
def test_Nested( self ):
self.site._setObject( 'portal_types', TypesTool() )
- fti = FTIDATA_TOPIC[0].copy()
- self.site.portal_types._setObject( 'Topic', FTI(**fti) )
+ self.site.portal_types._setObject('Topic', FTI(id='Topic',
+ product='CMFTopic', factory='addTopic'))
topic = self._makeOne('top')
topic._setPortalTypeName('Topic')
Deleted: CMF/branches/tseaver-viewification/CMFTopic/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFTopic/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFTopic/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,41 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFTopic tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite('Products.CMFTopic.tests',[
- 'test_DateC',
- 'test_ListC',
- 'test_SIC',
- 'test_SortC',
- 'test_SSC',
- 'test_Topic',
- ])
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
Deleted: CMF/branches/tseaver-viewification/CMFUid/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFUid/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFUid/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,38 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMFUid tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite('Products.CMFUid.tests',[
- 'test_uidannotation',
- 'test_uidgeneration',
- 'test_uidhandling',
- ])
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
Modified: CMF/branches/tseaver-viewification/CMFUid/tests/test_uidhandling.py
===================================================================
--- CMF/branches/tseaver-viewification/CMFUid/tests/test_uidhandling.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/CMFUid/tests/test_uidhandling.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -24,13 +24,6 @@
from Products.CMFCore.tests.base.testcase import SecurityTest
-def removeUnnecessaryIndexes(catalog):
- indexes = [id[0] for id in catalog.enumerateIndexes()]
- columns = catalog.enumerateColumns()
- catalog.manage_delIndex(indexes)
- catalog.manage_delColumn(columns)
-
-
class DummyUid:
"""A dummy uid that surely is of different type of the generated ones.
"""
@@ -58,8 +51,6 @@
self.root._setObject('dummy', DummyContent(id='dummy'))
self.root._setObject('dummy2', DummyContent(id='dummy2'))
- removeUnnecessaryIndexes(self.root.portal_catalog)
-
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFUid.interfaces import IUniqueIdBrainQuery
Deleted: CMF/branches/tseaver-viewification/DCWorkflow/tests/test_all.py
===================================================================
--- CMF/branches/tseaver-viewification/DCWorkflow/tests/test_all.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/DCWorkflow/tests/test_all.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,37 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" DCWorkflow tests.
-
-$Id$
-"""
-
-from unittest import main
-import Testing
-import Zope2
-Zope2.startup()
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-def suite():
- return build_test_suite('Products.DCWorkflow.tests',[
- 'test_DCWorkflow',
- 'test_roles',
- ])
-
-def test_suite():
- # Just to silence the top-level test.py
- return None
-
-if __name__ == '__main__':
- main(defaultTest='suite')
Modified: CMF/branches/tseaver-viewification/GenericSetup/CHANGES.txt
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/CHANGES.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/CHANGES.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,5 +1,10 @@
GenericSetup Product Changelog
+ After GenericSetup 1.0
+
+ - Forward ported changes from GenericSetup 0.11 and 0.12 (which were
+ created in a separate repository).
+
GenericSetup 1.0 (2005/09/23)
- CVS tag: GenericSetup-1_0
@@ -11,6 +16,25 @@
- Forward ported fix for tools with non unique IDs from CMFSetup.
+ GenericSetup-0.12 (2005/08/29)
+
+ - CVS tag: GenericSetup-0_12
+
+ - Import requests now create reports (by default) which record any
+ status messages generated by the profile's steps.
+
+ GenericSetup-0.11 (2005/08/23)
+
+ - CVS tag: GenericSetup-0_11
+
+ - Added report of messages generated by import to the "Import" tab.
+
+ - Consolidated ISetupContext implementation into base class,
+ 'SetupContextBase'.
+
+ - Added 'note', 'listNotes', and 'clearNotes' methods to ISetupContext,
+ to allow plugins to record information about the state of the operation.
+
GenericSetup 0.10 (2005/08/11)
- CVS tag: GenericSetup-0_10
Modified: CMF/branches/tseaver-viewification/GenericSetup/MailHost/exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/MailHost/exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/MailHost/exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -44,5 +44,5 @@
"""
self.context.smtp_host = str(node.getAttribute('smtp_host'))
self.context.smtp_port = int(node.getAttribute('smtp_port'))
- self.context.smtp_uid = node.getAttribute('smtp_uid')
- self.context.smtp_pwd = node.getAttribute('smtp_pwd')
+ self.context.smtp_uid = node.getAttribute('smtp_uid').encode('utf-8')
+ self.context.smtp_pwd = node.getAttribute('smtp_pwd').encode('utf-8')
Modified: CMF/branches/tseaver-viewification/GenericSetup/MailHost/tests/test_exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/MailHost/tests/test_exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/MailHost/tests/test_exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -18,13 +18,9 @@
import unittest
import Testing
-import Products.Five
-import Products.GenericSetup.MailHost
-from Products.Five import zcml
from Products.GenericSetup.testing import NodeAdapterTestCase
-from zope.app.tests.placelesssetup import PlacelessSetup
+from Products.GenericSetup.testing import PlacelessSetup
-
_MAILHOST_XML = """\
<object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
smtp_port="25" smtp_pwd="" smtp_uid=""/>
@@ -39,7 +35,20 @@
return MailHostNodeAdapter
+ def _verifyImport(self, obj):
+ self.assertEqual(type(obj.smtp_host), str)
+ self.assertEqual(obj.smtp_host, 'localhost')
+ self.assertEqual(type(obj.smtp_port), int)
+ self.assertEqual(obj.smtp_port, 25)
+ self.assertEqual(type(obj.smtp_pwd), str)
+ self.assertEqual(obj.smtp_pwd, '')
+ self.assertEqual(type(obj.smtp_uid), str)
+ self.assertEqual(obj.smtp_uid, '')
+
def setUp(self):
+ import Products.Five
+ from Products.Five import zcml
+ import Products.GenericSetup.MailHost
from Products.MailHost.MailHost import MailHost
PlacelessSetup.setUp(self)
Modified: CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -55,7 +55,8 @@
indexed_attrs = []
for child in node.childNodes:
if child.nodeName == 'indexed_attr':
- indexed_attrs.append(child.getAttribute('value'))
+ indexed_attrs.append(
+ child.getAttribute('value').encode('utf-8'))
self.context.indexed_attrs = indexed_attrs
self.context.clear()
@@ -104,8 +105,8 @@
def importNode(self, node, mode=PURGE):
"""Import the object from the DOM node.
"""
- self.context._edit(node.getAttribute('since_field'),
- node.getAttribute('until_field'))
+ self.context._edit(node.getAttribute('since_field').encode('utf-8'),
+ node.getAttribute('until_field').encode('utf-8'))
self.context.clear()
@@ -173,7 +174,8 @@
def importNode(self, node, mode=PURGE):
"""Import the object from the DOM node.
"""
- self.context.setExpression(node.getAttribute('expression'))
+ self.context.setExpression(
+ node.getAttribute('expression').encode('utf-8'))
self.context.clear()
Modified: CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/tests/test_exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/tests/test_exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/PluginIndexes/tests/test_exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -22,7 +22,7 @@
import Products.GenericSetup.PluginIndexes
from Products.Five import zcml
from Products.GenericSetup.testing import NodeAdapterTestCase
-from zope.app.tests.placelesssetup import PlacelessSetup
+from Products.GenericSetup.testing import PlacelessSetup
_DATE_XML = """\
Modified: CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -54,7 +54,8 @@
for child in node.childNodes:
if child.nodeName == 'element':
element = element_factory.instantiate(
- child.getAttribute('group'), child.getAttribute('name'))
+ child.getAttribute('group').encode('utf-8'),
+ child.getAttribute('name').encode('utf-8'))
pipeline.append(element)
self.context._pipeline = tuple(pipeline)
#clear lexicon
@@ -105,6 +106,7 @@
indexed_attrs = []
for child in node.childNodes:
if child.nodeName == 'indexed_attr':
- indexed_attrs.append(child.getAttribute('value'))
+ indexed_attrs.append(
+ child.getAttribute('value').encode('utf-8'))
self.context.indexed_attrs = indexed_attrs
self.context.clear()
Modified: CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/tests/test_exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/tests/test_exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/ZCTextIndex/tests/test_exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -24,7 +24,7 @@
import Products.GenericSetup.ZCTextIndex
from Products.Five import zcml
from Products.GenericSetup.testing import NodeAdapterTestCase
-from zope.app.tests.placelesssetup import PlacelessSetup
+from Products.GenericSetup.testing import PlacelessSetup
class _extra:
Modified: CMF/branches/tseaver-viewification/GenericSetup/ZCatalog/tests/test_exportimport.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/ZCatalog/tests/test_exportimport.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/ZCatalog/tests/test_exportimport.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -24,8 +24,8 @@
from Products.Five import zcml
from Products.GenericSetup.interfaces import INodeExporter
from Products.GenericSetup.testing import NodeAdapterTestCase
+from Products.GenericSetup.testing import PlacelessSetup
from Products.GenericSetup.utils import PrettyDocument
-from zope.app.tests.placelesssetup import PlacelessSetup
class _extra:
Modified: CMF/branches/tseaver-viewification/GenericSetup/configure.zcml
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/configure.zcml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/configure.zcml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -10,4 +10,40 @@
<include package=".ZCTextIndex"/>
+ <adapter
+ factory=".content.CSVAwareFileAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemExporter"
+ for="Products.GenericSetup.interfaces.ICSVAware"
+ />
+
+ <adapter
+ factory=".content.CSVAwareFileAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemImporter"
+ for="Products.GenericSetup.interfaces.ICSVAware"
+ />
+
+ <adapter
+ factory=".content.INIAwareFileAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemExporter"
+ for="Products.GenericSetup.interfaces.IINIAware"
+ />
+
+ <adapter
+ factory=".content.INIAwareFileAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemImporter"
+ for="Products.GenericSetup.interfaces.IINIAware"
+ />
+
+ <adapter
+ factory=".content.DAVAwareFileAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemExporter"
+ for="Products.GenericSetup.interfaces.IDAVAware"
+ />
+
+ <adapter
+ factory=".content.DAVAwareFileAdapter"
+ provides="Products.GenericSetup.interfaces.IFilesystemImporter"
+ for="Products.GenericSetup.interfaces.IDAVAware"
+ />
+
</configure>
Copied: CMF/branches/tseaver-viewification/GenericSetup/content.py (from rev 40248, CMF/trunk/GenericSetup/content.py)
Modified: CMF/branches/tseaver-viewification/GenericSetup/context.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/context.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/context.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -17,6 +17,7 @@
$Id$
"""
+import logging
import os
import time
from StringIO import StringIO
@@ -40,8 +41,58 @@
from interfaces import IExportContext
from interfaces import IImportContext
+from interfaces import IWriteLogger
from permissions import ManagePortal
+
+class Logger:
+
+ implements(IWriteLogger)
+
+ def __init__(self, id, messages):
+ """Initialize the logger with a name and an optional level.
+ """
+ self._id = id
+ self._messages = messages
+ self._logger = logging.getLogger('GenericSetup.%s' % id)
+
+ def debug(self, msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'DEBUG'.
+ """
+ self.log(logging.DEBUG, msg, *args, **kwargs)
+
+ def info(self, msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'INFO'.
+ """
+ self.log(logging.INFO, msg, *args, **kwargs)
+
+ def warning(self, msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'WARNING'.
+ """
+ self.log(logging.WARNING, msg, *args, **kwargs)
+
+ def error(self, msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'ERROR'.
+ """
+ self.log(logging.ERROR, msg, *args, **kwargs)
+
+ def exception(self, msg, *args):
+ """Convenience method for logging an ERROR with exception information.
+ """
+ self.error(msg, *args, **{'exc_info': 1})
+
+ def critical(self, msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'CRITICAL'.
+ """
+ self.log(logging.CRITICAL, msg, *args, **kwargs)
+
+ def log(self, level, msg, *args, **kwargs):
+ """Log 'msg % args' with the integer severity 'level'.
+ """
+ self._messages.append((level, self._id, msg))
+ self._logger.log(level, msg, *args, **kwargs)
+
+
class BaseContext( Implicit ):
security = ClassSecurityInfo()
@@ -50,7 +101,8 @@
self._tool = tool
self._site = aq_parent( aq_inner( tool ) )
- self._notes = []
+ self._loggers = {}
+ self._messages = []
self._encoding = encoding
security.declareProtected( ManagePortal, 'getSite' )
@@ -70,17 +122,31 @@
security.declareProtected( ManagePortal, 'getEncoding' )
def getEncoding( self ):
- """ See ISetupContext..
+ """ See ISetupContext.
"""
return self._encoding
- security.declareProtected( ManagePortal, 'notes' )
- def note( self, category, message ):
+ security.declareProtected( ManagePortal, 'getLogger' )
+ def getLogger( self, name ):
+ """ See ISetupContext.
+ """
+ return self._loggers.setdefault(name, Logger(name, self._messages))
+ security.declareProtected( ManagePortal, 'listNotes' )
+ def listNotes(self):
+
""" See ISetupContext.
"""
- self._notes.append( ( category, message ) )
+ return self._messages[:]
+ security.declareProtected( ManagePortal, 'clearNotes' )
+ def clearNotes(self):
+
+ """ See ISetupContext.
+ """
+ self._messages[:] = []
+
+
class DirectoryImportContext( BaseContext ):
implements(IImportContext)
Modified: CMF/branches/tseaver-viewification/GenericSetup/interfaces.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/interfaces.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/interfaces.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -48,16 +48,18 @@
o Return None if the data should not be encoded.
"""
- def note(category, message):
+ def getLogger(name):
+ """ Get a logger with the specified name, creating it if necessary.
+ """
- """ Record a logging message from within a handler.
+ def listNotes():
+ """ Return notes recorded by this context.
+
+ o Result a sequence of (component, message) tuples
+ """
- o 'category' is a string defining the source of the message.
-
- o 'message' is the text of the message itself.
-
- o XXX This API may disappear soon, to be replaced by a more
- general annotation.
+ def clearNotes():
+ """ Clear all notes recorded by this context.
"""
class IImportContext( ISetupContext ):
@@ -526,6 +528,40 @@
"""
+class IWriteLogger(Interface):
+
+ """Write methods used by the python logging Logger.
+ """
+
+ def debug(msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'DEBUG'.
+ """
+
+ def info(msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'INFO'.
+ """
+
+ def warning(msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'WARNING'.
+ """
+
+ def error(msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'ERROR'.
+ """
+
+ def exception(msg, *args):
+ """Convenience method for logging an ERROR with exception information.
+ """
+
+ def critical(msg, *args, **kwargs):
+ """Log 'msg % args' with severity 'CRITICAL'.
+ """
+
+ def log(level, msg, *args, **kwargs):
+ """Log 'msg % args' with the integer severity 'level'.
+ """
+
+
class INodeExporter(Interface):
"""Node exporter.
@@ -544,3 +580,119 @@
def importNode(node, mode=PURGE):
"""Import the object from the DOM node.
"""
+
+class IFilesystemExporter(Interface):
+ """ Plugin interface for site structure export.
+ """
+ def export(export_context, subdir, root=False):
+ """ Export our 'context' using the API of 'export_context'.
+
+ o 'export_context' must implement
+ Products.GenericSupport.interfaces.IExportContext.
+
+ o 'subdir', if passed, is the relative subdirectory containing our
+ context within the site.
+
+ o 'root', if true, indicates that the current context is the
+ "root" of an import (this may be used to adjust paths when
+ interacting with the context).
+ """
+
+ def listExportableItems():
+ """ Return a sequence of the child items to be exported.
+
+ o Each item in the returned sequence will be a tuple,
+ (id, object, adapter) where adapter must implement
+ IFilesystemExporter.
+ """
+
+class IFilesystemImporter(Interface):
+ """ Plugin interface for site structure export.
+ """
+ def import_(import_context, subdir, root=False):
+ """ Import our 'context' using the API of 'import_context'.
+
+ o 'import_context' must implement
+ Products.GenericSupport.interfaces.IImportContext.
+
+ o 'subdir', if passed, is the relative subdirectory containing our
+ context within the site.
+
+ o 'root', if true, indicates that the current context is the
+ "root" of an import (this may be used to adjust paths when
+ interacting with the context).
+ """
+
+class IContentFactory(Interface):
+ """ Adapter interface for factories specific to a container.
+ """
+ def __call__(id):
+ """ Return a new instance, seated in the context under 'id'.
+ """
+
+class IContentFactoryName(Interface):
+ """ Adapter interface for finding the name of the ICF for an object.
+ """
+ def __call__():
+ """ Return a string, suitable for looking up an IContentFactory.
+
+ o The string should allow finding a factory for our context's
+ container which would create an "empty" instance of the same
+ type as our context.
+ """
+
+class ICSVAware(Interface):
+ """ Interface for objects which dump / load 'text/comma-separated-values'.
+ """
+ def getId():
+ """ Return the Zope id of the object.
+ """
+
+ def as_csv():
+ """ Return a string representing the object as CSV.
+ """
+
+ def put_csv(fd):
+ """ Parse CSV and update the object.
+
+ o 'fd' must be a file-like object whose 'read' method returns
+ CSV text parseable by the 'csv.reader'.
+ """
+
+class IINIAware(Interface):
+ """ Interface for objects which dump / load INI-format files..
+ """
+ def getId():
+ """ Return the Zope id of the object.
+ """
+
+ def as_ini():
+ """ Return a string representing the object as INI.
+ """
+
+ def put_ini(stream_or_text):
+ """ Parse INI-formatted text and update the object.
+
+ o 'stream_or_text' must be either a string, or else a stream
+ directly parseable by ConfigParser.
+ """
+
+class IDAVAware(Interface):
+ """ Interface for objects which handle their own FTP / DAV operations.
+ """
+ def getId():
+ """ Return the Zope id of the object.
+ """
+
+ def manage_FTPget():
+ """ Return a string representing the object as a file.
+ """
+
+ def PUT(REQUEST, RESPONSE):
+ """ Parse file content and update the object.
+
+ o 'REQUEST' will have a 'get' method, which will have the
+ content object in its "BODY" key. It will also have 'get_header'
+ method, whose headers (e.g., "Content-Type") may affect the
+ processing of the body.
+ """
Modified: CMF/branches/tseaver-viewification/GenericSetup/rolemap.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/rolemap.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/rolemap.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -60,6 +60,7 @@
"""
site = context.getSite()
encoding = context.getEncoding()
+ logger = context.getLogger('rolemap')
if context.shouldPurge():
@@ -102,7 +103,7 @@
, permission[ 'acquire' ]
)
- return 'Role / permission map imported.'
+ logger.info('Role / permission map imported.')
def exportRolemap( context ):
@@ -131,12 +132,14 @@
"""
site = context.getSite()
+ logger = context.getLogger('rolemap')
+
rc = RolemapConfigurator( site ).__of__( site )
text = rc.generateXML()
context.writeDataFile( _FILENAME, text, 'text/xml' )
- return 'Role / permission map exported.'
+ logger.info('Role / permission map exported.')
class RolemapConfigurator(ConfiguratorBase):
Modified: CMF/branches/tseaver-viewification/GenericSetup/testing.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/testing.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/testing.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -24,12 +24,20 @@
from interfaces import INodeImporter
from utils import PrettyDocument
+try:
+ from zope.app.testing.placelesssetup import PlacelessSetup
+except ImportError: # BBB, Zope3 < 3.1
+ from zope.app.tests.placelesssetup import PlacelessSetup
+
class NodeAdapterTestCase(unittest.TestCase):
def _populate(self, obj):
pass
+ def _verifyImport(self, obj):
+ pass
+
def test_z3interfaces(self):
verifyClass(INodeExporter, self._getTargetClass())
verifyClass(INodeImporter, self._getTargetClass())
@@ -42,5 +50,6 @@
def test_importNode(self):
node = parseString(self._XML).documentElement
self.assertEqual(INodeImporter(self._obj).importNode(node), None)
+ self._verifyImport(self._obj)
node = INodeExporter(self._obj).exportNode(PrettyDocument())
self.assertEqual(node.toprettyxml(' '), self._XML)
Modified: CMF/branches/tseaver-viewification/GenericSetup/tests/common.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/tests/common.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/tests/common.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -174,12 +174,26 @@
self._compareDOM( found, data )
+class DummyLogger:
+
+ def __init__(self, id, messages):
+ self._id = id
+ self._messages = messages
+
+ def info(self, msg, *args, **kwargs):
+ self._messages.append((20, self._id, msg))
+
+ def warning(self, msg, *args, **kwargs):
+ self._messages.append((30, self._id, msg))
+
+
class DummyExportContext:
def __init__( self, site, tool=None ):
self._site = site
self._tool = tool
self._wrote = []
+ self._notes = []
def getSite( self ):
return self._site
@@ -187,11 +201,15 @@
def getSetupTool( self ):
return self._tool
+ def getLogger(self, name):
+ return DummyLogger(name, self._notes)
+
def writeDataFile( self, filename, text, content_type, subdir=None ):
if subdir is not None:
filename = '%s/%s' % ( subdir, filename )
self._wrote.append( ( filename, text, content_type ) )
+
class DummyImportContext:
def __init__( self, site, purge=True, encoding=None, tool=None ):
@@ -211,6 +229,9 @@
def getEncoding( self ):
return self._encoding
+ def getLogger(self, name):
+ return DummyLogger(name, self._notes)
+
def readDataFile( self, filename, subdir=None ):
if subdir is not None:
@@ -222,10 +243,7 @@
return self._purge
- def note( self, component, message ):
- self._notes.append( ( component, message ) )
-
def dummy_handler( context ):
pass
Modified: CMF/branches/tseaver-viewification/GenericSetup/tests/conformance.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/tests/conformance.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/tests/conformance.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -98,3 +98,66 @@
from zope.interface.verify import verifyClass
verifyClass( ISetupTool, self._getTargetClass() )
+
+class ConformsToIContentFactory:
+
+ def test_conforms_to_IContentFactory(self):
+
+ from Products.GenericSetup.interfaces import IContentFactory
+ from zope.interface.verify import verifyClass
+
+ verifyClass( IContentFactory, self._getTargetClass() )
+
+class ConformsToIContentFactoryName:
+
+ def test_conforms_to_IContentFactory(self):
+
+ from Products.GenericSetup.interfaces import IContentFactoryName
+ from zope.interface.verify import verifyClass
+
+ verifyClass( IContentFactoryName, self._getTargetClass() )
+
+class ConformsToIFilesystemExporter:
+
+ def test_conforms_to_IFilesystemExporter(self):
+
+ from Products.GenericSetup.interfaces import IFilesystemExporter
+ from zope.interface.verify import verifyClass
+
+ verifyClass( IFilesystemExporter, self._getTargetClass() )
+
+class ConformsToIFilesystemImporter:
+
+ def test_conforms_to_IFilesystemImporter(self):
+
+ from Products.GenericSetup.interfaces import IFilesystemImporter
+ from zope.interface.verify import verifyClass
+
+ verifyClass( IFilesystemImporter, self._getTargetClass() )
+
+class ConformsToIINIAware:
+
+ def test_conforms_to_IINIAware(self):
+
+ from Products.GenericSetup.interfaces import IINIAware
+ from zope.interface.verify import verifyClass
+
+ verifyClass (IINIAware, self._getTargetClass() )
+
+class ConformsToICSVAware:
+
+ def test_conforms_to_ICSVAware(self):
+
+ from Products.GenericSetup.interfaces import ICSVAware
+ from zope.interface.verify import verifyClass
+
+ verifyClass( ICSVAware, self._getTargetClass() )
+
+class ConformsToIDAVAware:
+
+ def test_conforms_to_IDAVAware(self):
+
+ from Products.GenericSetup.interfaces import IDAVAware
+ from zope.interface.verify import verifyClass
+
+ verifyClass( IDAVAware, self._getTargetClass() )
Copied: CMF/branches/tseaver-viewification/GenericSetup/tests/faux_objects.py (from rev 40248, CMF/trunk/GenericSetup/tests/faux_objects.py)
Copied: CMF/branches/tseaver-viewification/GenericSetup/tests/test_content.py (from rev 40248, CMF/trunk/GenericSetup/tests/test_content.py)
Modified: CMF/branches/tseaver-viewification/GenericSetup/tests/test_context.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/tests/test_context.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/tests/test_context.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -17,9 +17,8 @@
import unittest
import Testing
-import Zope2
-Zope2.startup()
+import logging
import os
import time
from StringIO import StringIO
@@ -47,6 +46,7 @@
pass
+
class DirectoryImportContextTests( FilesystemTestBase
, ConformsToISetupContext
, ConformsToIImportContext
@@ -59,6 +59,24 @@
from Products.GenericSetup.context import DirectoryImportContext
return DirectoryImportContext
+ def test_getLogger( self ):
+
+ site = DummySite( 'site' ).__of__( self.root )
+ ctx = self._makeOne( site, self._PROFILE_PATH )
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
+ logger = ctx.getLogger('foo')
+ logger.info('bar')
+
+ self.assertEqual( len( ctx.listNotes() ), 1 )
+ level, component, message = ctx.listNotes()[0]
+ self.assertEqual( level, logging.INFO )
+ self.assertEqual( component, 'foo' )
+ self.assertEqual( message, 'bar' )
+
+ ctx.clearNotes()
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
def test_readDataFile_nonesuch( self ):
FILENAME = 'nonesuch.txt'
@@ -314,6 +332,7 @@
self.failUnless( 'CVS' in names )
self.failUnless( '.svn' in names )
+
class DirectoryExportContextTests( FilesystemTestBase
, ConformsToISetupContext
, ConformsToIExportContext
@@ -326,6 +345,24 @@
from Products.GenericSetup.context import DirectoryExportContext
return DirectoryExportContext
+ def test_getLogger( self ):
+
+ site = DummySite( 'site' ).__of__( self.root )
+ ctx = self._makeOne( site, self._PROFILE_PATH )
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
+ logger = ctx.getLogger('foo')
+ logger.info('bar')
+
+ self.assertEqual( len( ctx.listNotes() ), 1 )
+ level, component, message = ctx.listNotes()[0]
+ self.assertEqual( level, logging.INFO )
+ self.assertEqual( component, 'foo' )
+ self.assertEqual( message, 'bar' )
+
+ ctx.clearNotes()
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
def test_writeDataFile_simple( self ):
from string import printable, digits
@@ -438,6 +475,23 @@
return site, tool, ctx.__of__( tool )
+ def test_getLogger( self ):
+
+ site, tool, ctx = self._makeOne()
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
+ logger = ctx.getLogger('foo')
+ logger.info('bar')
+
+ self.assertEqual( len( ctx.listNotes() ), 1 )
+ level, component, message = ctx.listNotes()[0]
+ self.assertEqual( level, logging.INFO )
+ self.assertEqual( component, 'foo' )
+ self.assertEqual( message, 'bar' )
+
+ ctx.clearNotes()
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
def test_ctorparms( self ):
ENCODING = 'latin-1'
@@ -690,6 +744,25 @@
from Products.GenericSetup.context import TarballExportContext
return TarballExportContext
+ def test_getLogger( self ):
+
+ site = DummySite( 'site' ).__of__( self.root )
+ ctx = self._getTargetClass()( site )
+
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
+ logger = ctx.getLogger('foo')
+ logger.info('bar')
+
+ self.assertEqual( len( ctx.listNotes() ), 1 )
+ level, component, message = ctx.listNotes()[0]
+ self.assertEqual( level, logging.INFO )
+ self.assertEqual( component, 'foo' )
+ self.assertEqual( message, 'bar' )
+
+ ctx.clearNotes()
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
def test_writeDataFile_simple( self ):
from string import printable
@@ -754,6 +827,27 @@
return self._getTargetClass()( *args, **kw )
+ def test_getLogger( self ):
+
+ site = DummySite( 'site' ).__of__( self.root )
+ site.setup_tool = DummyTool( 'setup_tool' )
+ tool = site.setup_tool
+ ctx = self._makeOne( tool, 'simple' )
+
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
+ logger = ctx.getLogger('foo')
+ logger.info('bar')
+
+ self.assertEqual( len( ctx.listNotes() ), 1 )
+ level, component, message = ctx.listNotes()[0]
+ self.assertEqual( level, logging.INFO )
+ self.assertEqual( component, 'foo' )
+ self.assertEqual( message, 'bar' )
+
+ ctx.clearNotes()
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
def test_writeDataFile_simple_image( self ):
from OFS.Image import Image
@@ -1024,6 +1118,25 @@
return folder._getOb( filename )
+ def test_getLogger( self ):
+
+ SNAPSHOT_ID = 'note'
+ site, tool, ctx = self._makeOne( SNAPSHOT_ID )
+
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
+ logger = ctx.getLogger('foo')
+ logger.info('bar')
+
+ self.assertEqual( len( ctx.listNotes() ), 1 )
+ level, component, message = ctx.listNotes()[0]
+ self.assertEqual( level, logging.INFO )
+ self.assertEqual( component, 'foo' )
+ self.assertEqual( message, 'bar' )
+
+ ctx.clearNotes()
+ self.assertEqual( len( ctx.listNotes() ), 0 )
+
def test_ctorparms( self ):
SNAPSHOT_ID = 'ctorparms'
Modified: CMF/branches/tseaver-viewification/GenericSetup/tests/test_tool.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/tests/test_tool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/tests/test_tool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -448,7 +448,7 @@
self.assertEqual( len( result[ 'steps' ] ), 1 )
self.assertEqual( result[ 'steps' ][ 0 ], 'step_registries' )
self.assertEqual( result[ 'messages' ][ 'step_registries' ]
- , 'Step registries exported'
+ , None
)
fileish = StringIO( result[ 'tarball' ] )
@@ -473,7 +473,7 @@
self.assertEqual( len( result[ 'steps' ] ), 1 )
self.assertEqual( result[ 'steps' ][ 0 ], 'step_registries' )
self.assertEqual( result[ 'messages' ][ 'step_registries' ]
- , 'Step registries exported'
+ , None
)
fileish = StringIO( result[ 'tarball' ] )
@@ -516,7 +516,7 @@
self.failUnless( 'step_registries' in result[ 'steps' ] )
self.assertEqual( result[ 'messages' ][ 'step_registries' ]
- , 'Step registries exported'
+ , None
)
fileish = StringIO( result[ 'tarball' ] )
@@ -553,7 +553,7 @@
self.assertEqual( len( result[ 'steps' ] ), 1 )
self.assertEqual( result[ 'steps' ][ 0 ], 'step_registries' )
self.assertEqual( result[ 'messages' ][ 'step_registries' ]
- , 'Step registries exported'
+ , None
)
snapshot = result[ 'snapshot' ]
@@ -853,7 +853,42 @@
self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
, DummyTool ) )
+ def test_required_tools_missing_acquired_nofail( self ):
+ from Products.GenericSetup.tool import TOOLSET_XML
+ from Products.GenericSetup.tool import importToolset
+
+ site = self._initSite()
+ parent_site = Folder()
+
+ mandatory = AnotherDummyTool()
+ mandatory._setId( 'mandatory' )
+ parent_site._setObject( 'mandatory', mandatory )
+
+ obligatory = AnotherDummyTool()
+ obligatory._setId( 'obligatory' )
+ parent_site._setObject( 'obligatory', obligatory )
+
+ site = site.__of__(parent_site)
+
+ # acquiring subobjects of a different class during import
+ # should not prevent new objects from being created if they
+ # don't exist in the site
+
+ context = DummyImportContext( site, tool=site.setup_tool )
+ context._files[ TOOLSET_XML ] = _REQUIRED_TOOLSET_XML
+
+ importToolset( context )
+
+ self.failIf( aq_base( site._getOb( 'mandatory' ) ) is mandatory )
+ self.failUnless( isinstance( aq_base( site._getOb( 'mandatory' ) )
+ , DummyTool ) )
+
+ self.failIf( aq_base( site._getOb( 'obligatory' ) ) is obligatory )
+ self.failUnless( isinstance( aq_base( site._getOb( 'obligatory' ) )
+ , DummyTool ) )
+
+
class DummyTool( Folder ):
pass
Modified: CMF/branches/tseaver-viewification/GenericSetup/tests/test_utils.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/tests/test_utils.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/tests/test_utils.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -246,6 +246,10 @@
def test__initProperties_normal(self):
node = parseString(_NORMAL_PROPERTY_EXPORT).documentElement
self.helpers._initProperties(node, PURGE)
+ self.assertEqual(type(self.helpers.context.foo_int), int)
+ self.assertEqual(type(self.helpers.context.foo_string), str)
+ self.assertEqual(type(self.helpers.context.foo_tokens), tuple)
+ self.assertEqual(type(self.helpers.context.foo_tokens[0]), str)
doc = self.helpers._doc = PrettyDocument()
node = doc.createElement('dummy')
Modified: CMF/branches/tseaver-viewification/GenericSetup/tool.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/tool.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/tool.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -23,6 +23,7 @@
from Acquisition import aq_base
from Globals import InitializeClass
from OFS.Folder import Folder
+from OFS.Image import File
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from zope.interface import implements
from zope.interface import implementedBy
@@ -52,6 +53,7 @@
""" Built-in handler for exporting import / export step registries.
"""
setup_tool = context.getSetupTool()
+ logger = context.getLogger('registries')
import_steps_xml = setup_tool.getImportStepRegistry().generateXML()
context.writeDataFile('import_steps.xml', import_steps_xml, 'text/xml')
@@ -59,7 +61,7 @@
export_steps_xml = setup_tool.getExportStepRegistry().generateXML()
context.writeDataFile('export_steps.xml', export_steps_xml, 'text/xml')
- return 'Step registries exported'
+ logger.info('Step registries exported.')
def importToolset(context):
@@ -67,10 +69,12 @@
"""
site = context.getSite()
encoding = context.getEncoding()
+ logger = context.getLogger('toolset')
xml = context.readDataFile(TOOLSET_XML)
if xml is None:
- return 'Toolset: Nothing to import.'
+ logger.info('Nothing to import.')
+ return
setup_tool = context.getSetupTool()
toolset = setup_tool.getToolsetRegistry()
@@ -90,7 +94,7 @@
tool_id = str(info['id'])
tool_class = _resolveDottedName(info['class'])
- existing = getattr(site, tool_id, None)
+ existing = getattr(aq_base(site), tool_id, None)
new_tool = tool_class()
try:
@@ -107,7 +111,7 @@
site._delObject(tool_id)
site._setObject(tool_id, tool_class())
- return 'Toolset imported.'
+ logger.info('Toolset imported.')
def exportToolset(context):
@@ -115,11 +119,12 @@
"""
setup_tool = context.getSetupTool()
toolset = setup_tool.getToolsetRegistry()
+ logger = context.getLogger('toolset')
xml = toolset.generateXML()
context.writeDataFile(TOOLSET_XML, xml, 'text/xml')
- return 'Toolset exported.'
+ logger.info('Toolset exported.')
class SetupTool(Folder):
@@ -219,7 +224,9 @@
steps.append(dependency)
message = self._doRunImportStep(step_id, context)
- messages[step_id] = message
+ message_list = filter(None, [message])
+ message_list.extend( ['%s: %s' % x[1:] for x in context.listNotes()] )
+ messages[step_id] = '\n'.join(message_list)
steps.append(step_id)
return { 'steps' : steps, 'messages' : messages }
@@ -236,7 +243,11 @@
for step in steps:
message = self._doRunImportStep(step, context)
- messages[step] = message
+ message_list = filter(None, [message])
+ message_list.extend( ['%s: %s' % x[1:]
+ for x in context.listNotes()] )
+ messages[step] = '\n'.join(message_list)
+ context.clearNotes()
return { 'steps' : steps, 'messages' : messages }
@@ -389,34 +400,45 @@
ids,
run_dependencies,
RESPONSE,
+ create_report=True,
):
""" Import the steps selected by the user.
"""
if not ids:
- message = 'No+steps+selected.'
+ summary = 'No+steps+selected.'
else:
steps_run = []
+ messages = {}
for step_id in ids:
result = self.runImportStep(step_id, run_dependencies)
steps_run.extend(result['steps'])
+ messages.update(result['messages'])
- message = 'Steps+run:%s' % '+,'.join(steps_run)
+ summary = 'Steps+run:%s' % '+,'.join(steps_run)
- RESPONSE.redirect('%s/manage_importSteps?manage_tabs_message=%s'
- % (self.absolute_url(), message))
+ if create_report:
+ name = self._mangleTimestampName('import-selected', 'log')
+ self._createReport(name, result['steps'], result['messages'])
+ return self.manage_importSteps(manage_tabs_message=summary,
+ messages=messages)
+
security.declareProtected(ManagePortal, 'manage_importSelectedSteps')
- def manage_importAllSteps(self, RESPONSE):
+ def manage_importAllSteps(self, RESPONSE, create_report=True):
""" Import all steps.
"""
result = self.runAllImportSteps()
- message = 'Steps+run:%s' % '+,'.join(result['steps'])
+ steps_run = 'Steps+run:%s' % '+,'.join(result['steps'])
- RESPONSE.redirect('%s/manage_importSteps?manage_tabs_message=%s'
- % (self.absolute_url(), message))
+ if create_report:
+ name = self._mangleTimestampName('import-all', 'log')
+ self._createReport(name, result['steps'], result['messages'])
+ return self.manage_importSteps(manage_tabs_message=steps_run,
+ messages=result['messages'])
+
security.declareProtected(ManagePortal, 'manage_exportSteps')
manage_exportSteps = PageTemplateFile('sutExportSteps', _wwwdir)
@@ -517,8 +539,7 @@
o If no ID is passed, generate one.
"""
if snapshot_id is None:
- timestamp = time.gmtime()
- snapshot_id = 'snapshot-%4d%02d%02d%02d%02d%02d' % timestamp[:6]
+ snapshot_id = self._mangleTimestampName('snapshot')
self.createSnapshot(snapshot_id)
@@ -713,6 +734,48 @@
, 'filename' : context.getArchiveFilename()
}
+ security.declarePrivate('_mangleTimestampName')
+ def _mangleTimestampName(self, prefix, ext=None):
+
+ """ Create a mangled ID using a timestamp.
+ """
+ timestamp = time.gmtime()
+ items = (prefix,) + timestamp[:6]
+
+ if ext is None:
+ fmt = '%s-%4d%02d%02d%02d%02d%02d'
+ else:
+ fmt = '%s-%4d%02d%02d%02d%02d%02d.%s'
+ items += (ext,)
+
+ return fmt % items
+
+ security.declarePrivate('_createReport')
+ def _createReport(self, name, steps, messages):
+
+ """ Record the results of a run.
+ """
+ lines = []
+ # Create report
+ for step in steps:
+ lines.append('=' * 65)
+ lines.append('Step: %s' % step)
+ lines.append('=' * 65)
+ msg = messages[step]
+ lines.extend(msg.split('\n'))
+ lines.append('')
+
+ report = '\n'.join(lines)
+ if isinstance(report, unicode):
+ report = report.encode('latin-1')
+
+ file = File(id=name,
+ title='',
+ file=report,
+ content_type='text/plain'
+ )
+ self._setObject(name, file)
+
InitializeClass(SetupTool)
_PLAINTEXT_DIFF_HEADER ="""\
Modified: CMF/branches/tseaver-viewification/GenericSetup/utils.py
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/utils.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/utils.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -542,8 +542,16 @@
return fragment
def _purgeProperties(self):
- #XXX: not implemented
- pass
+ for prop_map in self.context._propertyMap():
+ prop_id = prop_map['id']
+ if 'd' in prop_map.get('mode', 'wd') and not prop_id == 'title':
+ self.context._delProperty(prop_id)
+ else:
+ if prop_map.get('type') == 'multiple selection':
+ prop_value = ()
+ else:
+ prop_value = ''
+ self.context._updateProperty(prop_id, prop_value)
def _initProperties(self, node, mode):
self.context.i18n_domain = node.getAttribute('i18n:domain')
@@ -568,7 +576,7 @@
elements = []
for sub in child.childNodes:
if sub.nodeName == 'element':
- elements.append(sub.getAttribute('value'))
+ elements.append(sub.getAttribute('value').encode('utf-8'))
if elements or prop_map.get('type') == 'multiple selection':
prop_value = tuple(elements) or ()
@@ -577,6 +585,6 @@
else:
# if we pass a *string* to _updateProperty, all other values
# are converted to the right type
- prop_value = self._getNodeText(child)
+ prop_value = self._getNodeText(child).encode('utf-8')
obj._updateProperty(prop_id, prop_value)
Modified: CMF/branches/tseaver-viewification/GenericSetup/version.txt
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/version.txt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/version.txt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1 +1 @@
-GenericSetup-1.0
+GenericSetup-1.0+
Modified: CMF/branches/tseaver-viewification/GenericSetup/www/sutImportSteps.zpt
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/www/sutImportSteps.zpt 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/www/sutImportSteps.zpt 2005-11-19 17:53:07 UTC (rev 40249)
@@ -73,6 +73,19 @@
</tr>
</tbody>
+ <tbody tal:condition="options/messages | nothing">
+ <tr class="list-header">
+ <td colspan="4">Message Log</td>
+ </tr>
+ <tr valign="top"
+ tal:repeat="item options/messages/items">
+ <td tal:content="python: item[0]">STEP</td>
+ <td colspan="3"
+ tal:content="structure python: item[1].replace('\n', '<br />')"
+ >MESSAGE</td>
+ </tr>
+ </tbody>
+
</table>
</form>
Deleted: CMF/branches/tseaver-viewification/GenericSetup/xml/spcExport.xml
===================================================================
--- CMF/branches/tseaver-viewification/GenericSetup/xml/spcExport.xml 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/GenericSetup/xml/spcExport.xml 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,5 +0,0 @@
-<?xml version="1.0"?>
-<site xmlns:tal="http://xml.zope.org/namespaces/tal"
-><tal:span tal:define="prop_infos context/listSiteInfos"
- tal:replace="structure python: context.generatePropertyNodes(prop_infos)"/>
-</site>
Deleted: CMF/branches/tseaver-viewification/all_cmf_tests.py
===================================================================
--- CMF/branches/tseaver-viewification/all_cmf_tests.py 2005-11-19 15:56:54 UTC (rev 40248)
+++ CMF/branches/tseaver-viewification/all_cmf_tests.py 2005-11-19 17:53:07 UTC (rev 40249)
@@ -1,107 +0,0 @@
-#!/usr/bin/env python
-
-##############################################################################
-#
-# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" CMF tests.
-
-$Id$
-"""
-from warnings import warn
-
-import unittest
-import Testing
-import Zope2
-Zope2.startup()
-
-import getopt
-import sys
-
-from Products.CMFCore.tests.base.utils import build_test_suite
-
-
-# PackageName Required?
-CMF_PACKAGES = [ ( 'CMFCore', 1 )
- , ( 'CMFDefault', 1 )
- , ( 'CMFTopic', 1 )
- , ( 'DCWorkflow', 1 )
- , ( 'CMFActionIcons', 1 )
- , ( 'CMFSetup', 1 )
- , ( 'CMFUid', 1 )
- , ( 'CMFCalendar', 0 )
- , ( 'CMFCollector', 0 )
- , ( 'CMFStaging', 0 )
- , ( 'CMFWorkspaces', 0 )
- ]
-
-PACKAGES_UNDER_TEST = []
-
-def test_suite():
-
- suite = unittest.TestSuite()
-
- packages = PACKAGES_UNDER_TEST or CMF_PACKAGES
-
- for package_name, required in packages:
- dotted = 'Products.%s.tests' % package_name
- suite.addTest( build_test_suite( dotted
- , [ 'test_all' ]
- , required=required
- , suite_name='suite'
- ) )
-
- return suite
-
-def usage():
-
- USAGE = """\
-all_cmf_tests.py [-?] <package_name>*
-
-where
-
- package_name is the list of packages to be tested
- default: %s
-"""
-
- print USAGE % CMF_PACKAGES
- sys.exit( 2 )
-
-def main():
- warn( 'all_cmf_tests is deprecated and will be removed in CMF 1.7. '
- 'Please run the tests using \"zopectl test\" instead.'
- , DeprecationWarning
- )
-
- try:
- opts, args = getopt.getopt( sys.argv[1:], 'vq?' )
- except getopt.GetoptError:
- usage()
-
- sys.argv[ 1: ] = []
- PASSTHROUGH = ( '-v', '-q' )
-
- for k, v in opts:
-
- if k in PASSTHROUGH:
- sys.argv.append( k )
-
- if k == '-?' or k == '--help':
- usage()
-
- for arg in args:
- PACKAGES_UNDER_TEST.append( ( arg, 1 ) )
-
- unittest.main(defaultTest='test_suite')
-
-
-if __name__ == '__main__':
- main()
More information about the CMF-checkins
mailing list