[CMF-checkins] SVN: CMF/trunk/C - converted type info setup
handlers to new style
Yvo Schubbe
y.2005- at wcm-solutions.de
Wed Oct 19 13:42:55 EDT 2005
Log message for revision 39514:
- converted type info setup handlers to new style
- presettings for new type infos can now be loaded from type info settings in setup profiles
- updated CMFDefault and CMFCalendar default profile
Changed:
U CMF/trunk/CHANGES.txt
U CMF/trunk/CMFCalendar/profiles/default/types/Event.xml
U CMF/trunk/CMFCore/TypesTool.py
U CMF/trunk/CMFCore/__init__.py
D CMF/trunk/CMFCore/dtml/addTypeInfo.dtml
U CMF/trunk/CMFCore/exportimport/configure.zcml
A CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
A CMF/trunk/CMFCore/exportimport/typeinfo.py
A CMF/trunk/CMFCore/www/addTypeInfo.zpt
U CMF/trunk/CMFDefault/profiles/default/types/CMF_BTree_Folder.xml
U CMF/trunk/CMFDefault/profiles/default/types/Discussion_Item.xml
U CMF/trunk/CMFDefault/profiles/default/types/Document.xml
U CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml
U CMF/trunk/CMFDefault/profiles/default/types/File.xml
U CMF/trunk/CMFDefault/profiles/default/types/Folder.xml
U CMF/trunk/CMFDefault/profiles/default/types/Image.xml
U CMF/trunk/CMFDefault/profiles/default/types/Link.xml
U CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml
U CMF/trunk/CMFDefault/profiles/default/types/Topic.xml
U CMF/trunk/CMFSetup/tests/test_typeinfo.py
U CMF/trunk/CMFSetup/typeinfo.py
D CMF/trunk/CMFSetup/xml/ticTypeExport.xml
-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CHANGES.txt 2005-10-19 17:42:54 UTC (rev 39514)
@@ -2,6 +2,11 @@
New Features
+ - TypesTool: Improved add form for type info objects.
+ Presettings can now be loaded from type info settings in setup profiles.
+ This replaces the feature that did allow to load presettings from
+ registered (oldstyle) fti data.
+
- CMFCore.CachingPolicyManager: Caching policies can now control all the
Cache-Control tokens defined in the HTTP 1.1 spec (s-maxage, public,
private, no-transform). When no-cache is enabled, a Pragma: no-cache
Modified: CMF/trunk/CMFCalendar/profiles/default/types/Event.xml
===================================================================
--- CMF/trunk/CMFCalendar/profiles/default/types/Event.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCalendar/profiles/default/types/Event.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,30 +1,27 @@
<?xml version="1.0"?>
-<type-info id="Event" kind="Factory-based Type Information"
- i18n:domain="cmf_calendar"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Event</property>
- <property name="description" i18n:translate="">Events are objects for use in Calendar topical queries on the catalog.</property>
- <property name="content_icon">event_icon.gif</property>
- <property name="content_meta_type">CMF Event</property>
- <property name="product">CMFCalendar</property>
- <property name="factory">addEvent</property>
- <property name="immediate_view">event_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="event_view"/>
- <alias from="view" to="event_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/event_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/event_edit_form"
- category="object" visible="True">
- <permission>Change portal events</permission>
- </action>
-</type-info>
+<object name="Event" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_calendar"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Event</property>
+ <property name="description"
+ i18n:translate="">Events are objects for use in Calendar topical queries on the catalog.</property>
+ <property name="content_icon">event_icon.gif</property>
+ <property name="content_meta_type">CMF Event</property>
+ <property name="product">CMFCalendar</property>
+ <property name="factory">addEvent</property>
+ <property name="immediate_view">event_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="event_view"/>
+ <alias from="view" to="event_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/event_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/event_edit_form" visible="True">
+ <permission value="Change portal events"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFCore/TypesTool.py
===================================================================
--- CMF/trunk/CMFCore/TypesTool.py 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCore/TypesTool.py 2005-10-19 17:42:54 UTC (rev 39514)
@@ -17,6 +17,7 @@
from sys import exc_info
from warnings import warn
+from xml.dom.minidom import parseString
import Products
from AccessControl import ClassSecurityInfo
@@ -32,6 +33,8 @@
from zope.i18nmessageid import MessageID
from zope.interface import implements
+from Products.GenericSetup.interfaces import INodeImporter
+
from ActionProviderBase import ActionProviderBase
from exceptions import AccessControl_Unauthorized
from exceptions import BadRequest
@@ -556,16 +559,7 @@
InitializeClass( FactoryTypeInformation )
-def manage_addFactoryTIForm(self, REQUEST):
- """ Get the add form for factory-based type infos.
- """
- addTIForm = DTMLFile('addTypeInfo', _dtmldir).__of__(self)
- ttool = getToolByName(self, 'portal_types')
- return addTIForm( self, REQUEST,
- add_meta_type=FactoryTypeInformation.meta_type,
- types=ttool.listDefaultTypeInformation() )
-
class ScriptableTypeInformation( TypeInformation ):
"""
@@ -623,20 +617,87 @@
InitializeClass( ScriptableTypeInformation )
-def manage_addScriptableTIForm(self, REQUEST):
+
+_addTypeInfo_template = PageTemplateFile('addTypeInfo.zpt', _wwwdir)
+
+def manage_addFactoryTIForm(dispatcher, REQUEST):
+ """ Get the add form for factory-based type infos.
+ """
+ template = _addTypeInfo_template.__of__(dispatcher)
+ meta_type = FactoryTypeInformation.meta_type
+ return template(add_meta_type=meta_type,
+ profiles=_getProfileInfo(dispatcher, meta_type))
+
+def manage_addScriptableTIForm(dispatcher, REQUEST):
""" Get the add form for scriptable type infos.
"""
- addTIForm = DTMLFile('addTypeInfo', _dtmldir).__of__(self)
- ttool = getToolByName(self, 'portal_types')
- return addTIForm( self, REQUEST,
- add_meta_type=ScriptableTypeInformation.meta_type,
- types=ttool.listDefaultTypeInformation() )
+ template = _addTypeInfo_template.__of__(dispatcher)
+ meta_type = ScriptableTypeInformation.meta_type
+ return template(add_meta_type=meta_type,
+ profiles=_getProfileInfo(dispatcher, meta_type))
+def _getProfileInfo(dispatcher, meta_type):
+ profiles = []
+ stool = getToolByName(dispatcher, 'portal_setup', None)
+ if stool:
+ for info in stool.listContextInfos():
+ type_ids = []
+ context = stool._getImportContext(info['id'])
+ filenames = context.listDirectory('types')
+ if filenames is None:
+ continue
+ for filename in filenames:
+ body = context.readDataFile(filename, subdir='types')
+ if body is None:
+ continue
+ root = parseString(body).documentElement
+ if root.getAttribute('meta_type') == meta_type:
+ type_id = root.getAttribute('name')
+ type_ids.append(type_id)
+ if not type_ids:
+ continue
+ type_ids.sort()
+ profiles.append({'id': info['id'],
+ 'title': info['title'],
+ 'type_ids': tuple(type_ids)})
+ return tuple(profiles)
-# Provide aliases for backward compatibility.
-ContentFactoryMetadata = FactoryTypeInformation
-ContentTypeInformation = ScriptableTypeInformation
+def manage_addTypeInfo(dispatcher, add_meta_type, id, settings_id='',
+ REQUEST=None):
+ """Add a new TypeInformation object of type 'add_meta_type' with ID 'id'.
+ """
+ settings_node = None
+ if settings_id:
+ stool = getToolByName(dispatcher, 'portal_setup', None)
+ if stool:
+ profile_id, type_id = settings_id.split('/')
+ context = stool._getImportContext(profile_id)
+ filenames = context.listDirectory('types')
+ for filename in filenames or ():
+ body = context.readDataFile(filename, subdir='types')
+ if body is not None:
+ root = parseString(body).documentElement
+ if root.getAttribute('name') != type_id:
+ continue
+ if root.getAttribute('meta_type') == add_meta_type:
+ settings_node = root
+ if not id:
+ id = type_id
+ break
+ for mt in Products.meta_types:
+ if mt['name'] == add_meta_type:
+ klass = mt['instance']
+ break
+ else:
+ raise ValueError('Meta type %s is not a type class.' % add_meta_type)
+ obj = klass(id)
+ if settings_node:
+ INodeImporter(obj).importNode(settings_node)
+ dispatcher._setObject(id, obj)
+ if REQUEST:
+ return dispatcher.manage_main(dispatcher, REQUEST)
+
allowedTypes = [
'Script (Python)',
'Python Method',
Modified: CMF/trunk/CMFCore/__init__.py
===================================================================
--- CMF/trunk/CMFCore/__init__.py 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCore/__init__.py 2005-10-19 17:42:54 UTC (rev 39514)
@@ -150,7 +150,8 @@
context.registerClass(
TypesTool.FactoryTypeInformation,
permission=ManagePortal,
- constructors=( TypesTool.manage_addFactoryTIForm, ),
+ constructors=(TypesTool.manage_addFactoryTIForm,
+ TypesTool.manage_addTypeInfo),
icon='images/typeinfo.gif',
visibility=None,
interfaces=(ITypeInformation,))
@@ -158,7 +159,8 @@
context.registerClass(
TypesTool.ScriptableTypeInformation,
permission=ManagePortal,
- constructors=( TypesTool.manage_addScriptableTIForm, ),
+ constructors=(TypesTool.manage_addScriptableTIForm,
+ TypesTool.manage_addTypeInfo),
icon='images/typeinfo.gif',
visibility=None,
interfaces=(ITypeInformation,))
Deleted: CMF/trunk/CMFCore/dtml/addTypeInfo.dtml
===================================================================
--- CMF/trunk/CMFCore/dtml/addTypeInfo.dtml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCore/dtml/addTypeInfo.dtml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,57 +0,0 @@
-<dtml-let form_title="'Add %s' % add_meta_type">
-<dtml-if manage_page_header>
- <dtml-var manage_page_header>
- <dtml-var manage_form_title>
-<dtml-else>
- <html><head><title>&dtml-form_title;</title></head>
- <body>
- <h2>&dtml-form_title;</h2>
-</dtml-if>
-</dtml-let>
-
-<form action="&dtml.url-portal_types;/manage_addTypeInformation" method="POST">
-<input type="hidden" name="add_meta_type" value="&dtml-add_meta_type;" />
-<table cellspacing="0" cellpadding="2" border="0">
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Id
- </div>
- </td>
- <td align="left" valign="top">
- <input type="text" name="id" size="40" />
- </td>
- </tr>
- <tr>
- <td align="left" valign="top">
- <div class="form-label">
- Use default type information
- </div>
- </td>
- <td align="left" valign="top">
- <select name="typeinfo_name">
- <option value="">(None)</option>
- <dtml-in types sort>
- <option value="&dtml-sequence-key;">&dtml-sequence-key;</option>
- </dtml-in>
- </select>
- </td>
- </tr>
- <tr>
- <td align="left" valign="top">
- </td>
- <td align="left" valign="top">
- <div class="form-element">
- <input class="form-element" type="submit" name="submit"
- value=" Add " />
- </div>
- </td>
- </tr>
-</table>
-</form>
-
-<dtml-if manage_page_footer>
- <dtml-var manage_page_footer>
-<dtml-else>
- </body></html>
-</dtml-if>
Modified: CMF/trunk/CMFCore/exportimport/configure.zcml
===================================================================
--- CMF/trunk/CMFCore/exportimport/configure.zcml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCore/exportimport/configure.zcml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -100,4 +100,16 @@
for="Products.CMFCore.interfaces.ICookieCrumbler"
/>
+ <adapter
+ factory=".typeinfo.TypeInformationNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeExporter"
+ for="Products.CMFCore.interfaces.ITypeInformation"
+ />
+
+ <adapter
+ factory=".typeinfo.TypeInformationNodeAdapter"
+ provides="Products.GenericSetup.interfaces.INodeImporter"
+ for="Products.CMFCore.interfaces.ITypeInformation"
+ />
+
</configure>
Added: CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py 2005-10-19 17:42:54 UTC (rev 39514)
@@ -0,0 +1,83 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.
+#
+##############################################################################
+"""Types tool node adapter unit tests.
+
+$Id$
+"""
+
+import unittest
+import Testing
+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.GenericSetup.testing import NodeAdapterTestCase
+
+
+_FTI_XML = """\
+<object name="foo_fti" meta_type="Factory-based Type Information"
+ xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title"></property>
+ <property name="description"></property>
+ <property name="content_icon"></property>
+ <property name="content_meta_type"></property>
+ <property name="product"></property>
+ <property name="factory"></property>
+ <property name="immediate_view"></property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="foo"/>
+ <alias from="view" to="foo"/>
+ <action title="Foo" action_id="foo_action" category="Bar"
+ condition_expr="python:1" url_expr="string:${object_url}/foo"
+ visible="True"/>
+</object>
+"""
+
+
+class TypeInformationNodeAdapterTests(PlacelessSetup, NodeAdapterTestCase):
+
+ def _getTargetClass(self):
+ from Products.CMFCore.exportimport.typeinfo \
+ import TypeInformationNodeAdapter
+
+ return TypeInformationNodeAdapter
+
+ def setUp(self):
+ from Products.CMFCore.TypesTool import FactoryTypeInformation
+
+ PlacelessSetup.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
+
+ 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),
+ ))
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
Property changes on: CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: CMF/trunk/CMFCore/exportimport/typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/typeinfo.py 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCore/exportimport/typeinfo.py 2005-10-19 17:42:54 UTC (rev 39514)
@@ -0,0 +1,178 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.
+#
+##############################################################################
+"""Types tool node adapters.
+
+$Id$
+"""
+
+from Products.GenericSetup.interfaces import PURGE
+from Products.GenericSetup.utils import I18NURI
+from Products.GenericSetup.utils import NodeAdapterBase
+from Products.GenericSetup.utils import PropertyManagerHelpers
+
+from Products.CMFCore.interfaces import ITypeInformation
+
+
+class TypeInformationNodeAdapter(NodeAdapterBase, PropertyManagerHelpers):
+
+ """Node im- and exporter for TypeInformation.
+ """
+
+ __used_for__ = ITypeInformation
+
+ def exportNode(self, doc):
+ """Export the object as a DOM node.
+ """
+ self._doc = doc
+ node = self._getObjectNode('object')
+ node.setAttribute('xmlns:i18n', I18NURI)
+ node.appendChild(self._extractProperties())
+ node.appendChild(self._extractAliases())
+ node.appendChild(self._extractActions())
+ return node
+
+ def importNode(self, node, mode=PURGE):
+ """Import the object from the DOM node.
+ """
+ if mode == PURGE:
+ self._purgeProperties()
+ self._purgeAliases()
+ self._purgeActions()
+
+ self._initOldstyleProperties(node, mode)
+ self._initProperties(node, mode)
+ self._initAliases(node, mode)
+ self._initActions(node, mode)
+
+ def _extractAliases(self):
+ fragment = self._doc.createDocumentFragment()
+ aliases = self.context.getMethodAliases().items()
+ aliases.sort()
+ for k, v in aliases:
+ child = self._doc.createElement('alias')
+ child.setAttribute('from', k)
+ child.setAttribute('to', v)
+ fragment.appendChild(child)
+ return fragment
+
+ def _purgeAliases(self):
+ self.context.setMethodAliases({})
+
+ def _initAliases(self, node, mode):
+ aliases = self.context.getMethodAliases()
+ for child in node.childNodes:
+ # BBB: for CMF 1.5 profiles
+ # 'alias' nodes moved one level up.
+ if child.nodeName == 'aliases':
+ for sub in child.childNodes:
+ if sub.nodeName != 'alias':
+ continue
+ k = str(sub.getAttribute('from'))
+ v = str(sub.getAttribute('to'))
+ aliases[k] = v
+
+ if child.nodeName != 'alias':
+ continue
+ k = str(child.getAttribute('from'))
+ v = str(child.getAttribute('to'))
+ aliases[k] = v
+ self.context.setMethodAliases(aliases)
+
+ def _extractActions(self):
+ fragment = self._doc.createDocumentFragment()
+ actions = self.context.listActions()
+ for ai in actions:
+ ai_info = ai.getMapping()
+ child = self._doc.createElement('action')
+ child.setAttribute('title', ai_info['title'])
+ child.setAttribute('action_id', ai_info['id'])
+ child.setAttribute('category', ai_info['category'])
+ child.setAttribute('condition_expr', ai_info['condition'])
+ child.setAttribute('url_expr', ai_info['action'])
+ child.setAttribute('visible', str(bool(ai_info['visible'])))
+ for permission in ai_info['permissions']:
+ sub = self._doc.createElement('permission')
+ sub.setAttribute('value', permission)
+ child.appendChild(sub)
+ fragment.appendChild(child)
+ return fragment
+
+ def _purgeActions(self):
+ self.context._actions = ()
+
+ def _initActions(self, node, mode):
+ for child in node.childNodes:
+ if child.nodeName != 'action':
+ continue
+ title = child.getAttribute('title')
+ id = child.getAttribute('action_id')
+ category = child.getAttribute('category')
+ condition = child.getAttribute('condition_expr')
+ action = child.getAttribute('url_expr')
+ visible = self._convertToBoolean(child.getAttribute('visible'))
+ permissions = []
+ for sub in child.childNodes:
+ if sub.nodeName != 'permission':
+ continue
+ permission = sub.getAttribute('value')
+ # BBB: for CMF 1.5 profiles
+ # Permission name moved from node text to 'value'.
+ if not permission:
+ permission = self._getNodeText(sub)
+ permissions.append(permission)
+ self.context.addAction(id, title, action, condition,
+ tuple(permissions), category, visible)
+
+ def _initOldstyleProperties(self, node, mode):
+ if not node.hasAttribute('title'):
+ return
+ # BBB: for CMF 1.5 profiles
+ obj = self.context
+
+ title = node.getAttribute('title')
+ description = ''
+ content_meta_type = node.getAttribute('meta_type')
+ content_icon = node.getAttribute('icon')
+ immediate_view = node.getAttribute('immediate_view')
+ global_allow = self._convertToBoolean(node.getAttribute(
+ 'global_allow'))
+ filter_content_types = self._convertToBoolean(node.getAttribute(
+ 'filter_content_types'))
+ allowed_content_types = []
+ allow_discussion = self._convertToBoolean(node.getAttribute(
+ 'allow_discussion'))
+ for child in node.childNodes:
+ if child.nodeName == 'description':
+ description += self._getNodeText(child)
+ elif child.nodeName == 'allowed_content_type':
+ allowed_content_types.append(self._getNodeText(child))
+ obj._updateProperty('title', title)
+ obj._updateProperty('description', description)
+ obj._updateProperty('content_meta_type', content_meta_type)
+ obj._updateProperty('content_icon', content_icon)
+ obj._updateProperty('immediate_view', immediate_view)
+ obj._updateProperty('global_allow', global_allow)
+ obj._updateProperty('filter_content_types', filter_content_types)
+ obj._updateProperty('allowed_content_types', allowed_content_types)
+ obj._updateProperty('allow_discussion', allow_discussion)
+
+ if node.getAttribute('kind') == 'Factory-based Type Information':
+ product = node.getAttribute('product')
+ factory = node.getAttribute('factory')
+ obj._updateProperty('product', product)
+ obj._updateProperty('factory', factory)
+ else:
+ constructor_path = node.getAttribute('constructor_path')
+ permission = node.getAttribute('permission')
+ obj._updateProperty('constructor_path', constructor_path)
+ obj._updateProperty('permission', permission)
Property changes on: CMF/trunk/CMFCore/exportimport/typeinfo.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: CMF/trunk/CMFCore/www/addTypeInfo.zpt
===================================================================
--- CMF/trunk/CMFCore/www/addTypeInfo.zpt 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFCore/www/addTypeInfo.zpt 2005-10-19 17:42:54 UTC (rev 39514)
@@ -0,0 +1,47 @@
+<h1 tal:replace="structure context/manage_page_header">PAGE HEADER</h1>
+<h2 tal:define="form_title string:Add ${options/add_meta_type}"
+ tal:replace="structure context/manage_form_title">FORM TITLE</h2>
+
+<p class="form-help">A type information object defines a portal type.</p>
+
+<form action="manage_addTypeInfo" method="post">
+<input type="hidden" name="add_meta_type" value=""
+ tal:attributes="value options/add_meta_type" />
+<table cellspacing="0" cellpadding="2" border="0">
+ <tr>
+ <td>
+ <div class="form-label">ID</div>
+ </td>
+ <td>
+ <input type="text" name="id" size="40" />
+ </td>
+ </tr>
+ <tr tal:condition="options/profiles">
+ <td>
+ <div class="form-label">Presettings</div>
+ </td>
+ <td>
+ <select name="settings_id">
+ <option value="" selected="selected">(None)</option>
+ <optgroup label="PROFILE_TITLE"
+ tal:repeat="profile options/profiles"
+ tal:attributes="label profile/title">
+ <option value="SETTINGS_ID"
+ tal:repeat="type_id profile/type_ids"
+ tal:attributes="value string:${profile/id}/${type_id}"
+ tal:content="type_id">TYPE ID</option></optgroup>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+
+ </td>
+ <td>
+ <input class="form-element" type="submit" name="submit" value="Add" />
+ </td>
+ </tr>
+</table>
+</form>
+
+<h1 tal:replace="structure context/manage_page_footer">PAGE FOOTER</h1>
Modified: CMF/trunk/CMFDefault/profiles/default/types/CMF_BTree_Folder.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/CMF_BTree_Folder.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/CMF_BTree_Folder.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,55 +1,46 @@
<?xml version="1.0"?>
-<type-info id="CMF BTree Folder"
- kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">CMF BTree Folder</property>
- <property name="description" i18n:translate="">Folder for holding very large numbers of items.</property>
- <property name="content_icon">folder_icon.gif</property>
- <property name="content_meta_type">CMF BTree Folder</property>
- <property name="product">CMFCore</property>
- <property name="factory">manage_addCMFBTreeFolder</property>
- <property name="immediate_view">folder_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">False</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="index.html" to="index_html"/>
- <alias from="(Default)" to="index_html"/>
- <alias from="view" to="index_html"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}" category="object"
- visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/folder_edit_form"
- category="object" visible="True">
- <permission>Manage properties</permission>
- </action>
- <action action_id="localroles" title="Local Roles"
- condition_expr=""
- url_expr="string:${object_url}/folder_localrole_form"
- category="object" visible="True">
- <permission>Change local roles</permission>
- </action>
- <action action_id="folderContents" title="Folder contents"
- condition_expr=""
- url_expr="string:${object_url}/folder_contents"
- category="object" visible="True">
- <permission>List folder contents</permission>
- </action>
- <action action_id="new" title="New..." condition_expr=""
- url_expr="string:${object_url}/folder_factories"
- category="object" visible="False">
- <permission>Add portal content</permission>
- </action>
- <action action_id="rename_items" title="Rename items"
- condition_expr=""
- url_expr="string:${object_url}/folder_rename_form"
- category="object" visible="False">
- <permission>Add portal content</permission>
- </action>
-</type-info>
+<object name="CMF BTree Folder" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">CMF BTree Folder</property>
+ <property name="description"
+ i18n:translate="">Folder for holding very large numbers of items.</property>
+ <property name="content_icon">folder_icon.gif</property>
+ <property name="content_meta_type">CMF BTree Folder</property>
+ <property name="product">CMFCore</property>
+ <property name="factory">manage_addCMFBTreeFolder</property>
+ <property name="immediate_view">folder_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">False</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="index_html"/>
+ <alias from="index.html" to="index_html"/>
+ <alias from="view" to="index_html"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/folder_edit_form" visible="True">
+ <permission value="Manage properties"/>
+ </action>
+ <action title="Local Roles" action_id="localroles" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_localrole_form"
+ visible="True">
+ <permission value="Change local roles"/>
+ </action>
+ <action title="Folder contents" action_id="folderContents" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_contents"
+ visible="True">
+ <permission value="List folder contents"/>
+ </action>
+ <action title="New..." action_id="new" category="object" condition_expr=""
+ url_expr="string:${object_url}/folder_factories" visible="False">
+ <permission value="Add portal content"/>
+ </action>
+ <action title="Rename items" action_id="rename_items" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_rename_form"
+ visible="False">
+ <permission value="Add portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/Discussion_Item.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Discussion_Item.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/Discussion_Item.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,27 +1,23 @@
<?xml version="1.0"?>
-<type-info id="Discussion Item"
- kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Discussion Item</property>
- <property name="description" i18n:translate="">Discussion Items are documents which reply to other content.
-They should *not* be addable through the standard 'folder_factories' interface.</property>
- <property name="content_icon">discussionitem_icon.gif</property>
- <property name="content_meta_type">Discussion Item</property>
- <property name="product"></property>
- <property name="factory"></property>
- <property name="immediate_view"></property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="discussionitem_view"/>
- <alias from="view" to="discussionitem_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/discussionitem_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
-</type-info>
+<object name="Discussion Item" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Discussion Item</property>
+ <property name="description"
+ i18n:translate="">Discussion Items are documents which reply to other content.
+ They should *not* be addable through the standard 'folder_factories' interface.</property>
+ <property name="content_icon">discussionitem_icon.gif</property>
+ <property name="content_meta_type">Discussion Item</property>
+ <property name="product"></property>
+ <property name="factory"></property>
+ <property name="immediate_view"></property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="discussionitem_view"/>
+ <alias from="view" to="discussionitem_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/discussionitem_view" visible="True">
+ <permission value="View"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/Document.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Document.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/Document.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,39 +1,33 @@
<?xml version="1.0"?>
-<type-info id="Document"
- kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Document</property>
- <property name="description" i18n:translate="">Documents contain text that can be formatted using 'Structured Text.'
-They may also contain HTML, or "plain" text.</property>
- <property name="content_icon">document_icon.gif</property>
- <property name="content_meta_type">Document</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addDocument</property>
- <property name="immediate_view">metadata_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="gethtml" to="source_html"/>
- <alias from="(Default)" to="document_view"/>
- <alias from="view" to="document_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/document_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/document_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action action_id="metadata" title="Metadata"
- condition_expr=""
- url_expr="string:${object_url}/metadata_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+<object name="Document" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Document</property>
+ <property name="description"
+ i18n:translate="">Documents contain text that can be formatted using 'Structured Text.'
+ They may also contain HTML, or "plain" text.</property>
+ <property name="content_icon">document_icon.gif</property>
+ <property name="content_meta_type">Document</property>
+ <property name="product">CMFDefault</property>
+ <property name="factory">addDocument</property>
+ <property name="immediate_view">metadata_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="document_view"/>
+ <alias from="gethtml" to="source_html"/>
+ <alias from="view" to="document_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/document_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/document_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/Favorite.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,37 +1,31 @@
<?xml version="1.0"?>
-<type-info id="Favorite"
- kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Favorite</property>
- <property name="description" i18n:translate="">A Favorite is a Link to an intra-portal resource.</property>
- <property name="content_icon">link_icon.gif</property>
- <property name="content_meta_type">Favorite</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addFavorite</property>
- <property name="immediate_view">metadata_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="favorite_view"/>
- <alias from="view" to="favorite_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/favorite_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/link_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action action_id="metadata" title="Metadata"
- condition_expr=""
- url_expr="string:${object_url}/metadata_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+<object name="Favorite" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Favorite</property>
+ <property name="description"
+ i18n:translate="">A Favorite is a Link to an intra-portal resource.</property>
+ <property name="content_icon">link_icon.gif</property>
+ <property name="content_meta_type">Favorite</property>
+ <property name="product">CMFDefault</property>
+ <property name="factory">addFavorite</property>
+ <property name="immediate_view">metadata_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="favorite_view"/>
+ <alias from="view" to="favorite_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/favorite_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/link_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/File.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/File.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/File.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,41 +1,35 @@
<?xml version="1.0"?>
-<type-info id="File" kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">File</property>
- <property name="description" i18n:translate="">File objects can contain arbitrary downloadable files.</property>
- <property name="content_icon">file_icon.gif</property>
- <property name="content_meta_type">Portal File</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addFile</property>
- <property name="immediate_view">metadata_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="index_html"/>
- <alias from="view" to="file_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/file_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="download" title="Download"
- condition_expr="" url_expr="string:${object_url}"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/file_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action action_id="metadata" title="Metadata"
- condition_expr=""
- url_expr="string:${object_url}/metadata_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+<object name="File" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">File</property>
+ <property name="description"
+ i18n:translate="">File objects can contain arbitrary downloadable files.</property>
+ <property name="content_icon">file_icon.gif</property>
+ <property name="content_meta_type">Portal File</property>
+ <property name="product">CMFDefault</property>
+ <property name="factory">addFile</property>
+ <property name="immediate_view">metadata_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="index_html"/>
+ <alias from="view" to="file_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/file_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Download" action_id="download" category="object"
+ condition_expr="" url_expr="string:${object_url}" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/file_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/Folder.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Folder.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/Folder.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,54 +1,46 @@
<?xml version="1.0"?>
-<type-info id="Folder" kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Folder</property>
- <property name="description" i18n:translate="">Use folders to put content in categories.</property>
- <property name="content_icon">folder_icon.gif</property>
- <property name="content_meta_type">Portal Folder</property>
- <property name="product">CMFCore</property>
- <property name="factory">manage_addPortalFolder</property>
- <property name="immediate_view">folder_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">False</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="index.html" to="index_html"/>
- <alias from="(Default)" to="index_html"/>
- <alias from="view" to="index_html"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}" category="object"
- visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/folder_edit_form"
- category="object" visible="True">
- <permission>Manage properties</permission>
- </action>
- <action action_id="localroles" title="Local Roles"
- condition_expr=""
- url_expr="string:${object_url}/folder_localrole_form"
- category="object" visible="True">
- <permission>Change local roles</permission>
- </action>
- <action action_id="folderContents" title="Folder contents"
- condition_expr=""
- url_expr="string:${object_url}/folder_contents"
- category="object" visible="True">
- <permission>List folder contents</permission>
- </action>
- <action action_id="new" title="New..." condition_expr=""
- url_expr="string:${object_url}/folder_factories"
- category="object" visible="False">
- <permission>Add portal content</permission>
- </action>
- <action action_id="rename_items" title="Rename items"
- condition_expr=""
- url_expr="string:${object_url}/folder_rename_form"
- category="object" visible="False">
- <permission>Add portal content</permission>
- </action>
-</type-info>
+<object name="Folder" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Folder</property>
+ <property name="description"
+ i18n:translate="">Use folders to put content in categories.</property>
+ <property name="content_icon">folder_icon.gif</property>
+ <property name="content_meta_type">Portal Folder</property>
+ <property name="product">CMFCore</property>
+ <property name="factory">manage_addPortalFolder</property>
+ <property name="immediate_view">folder_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">False</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="index_html"/>
+ <alias from="index.html" to="index_html"/>
+ <alias from="view" to="index_html"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/folder_edit_form" visible="True">
+ <permission value="Manage properties"/>
+ </action>
+ <action title="Local Roles" action_id="localroles" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_localrole_form"
+ visible="True">
+ <permission value="Change local roles"/>
+ </action>
+ <action title="Folder contents" action_id="folderContents" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_contents"
+ visible="True">
+ <permission value="List folder contents"/>
+ </action>
+ <action title="New..." action_id="new" category="object" condition_expr=""
+ url_expr="string:${object_url}/folder_factories" visible="False">
+ <permission value="Add portal content"/>
+ </action>
+ <action title="Rename items" action_id="rename_items" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_rename_form"
+ visible="False">
+ <permission value="Add portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/Image.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Image.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/Image.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,36 +1,31 @@
<?xml version="1.0"?>
-<type-info id="Image" kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Image</property>
- <property name="description" i18n:translate="">Image objects can be embedded in Portal documents.</property>
- <property name="content_icon">image_icon.gif</property>
- <property name="content_meta_type">Portal Image</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addImage</property>
- <property name="immediate_view">metadata_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="index_html"/>
- <alias from="view" to="image_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/image_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/image_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action action_id="metadata" title="Metadata"
- condition_expr=""
- url_expr="string:${object_url}/metadata_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+<object name="Image" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Image</property>
+ <property name="description"
+ i18n:translate="">Image objects can be embedded in Portal documents.</property>
+ <property name="content_icon">image_icon.gif</property>
+ <property name="content_meta_type">Portal Image</property>
+ <property name="product">CMFDefault</property>
+ <property name="factory">addImage</property>
+ <property name="immediate_view">metadata_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="index_html"/>
+ <alias from="view" to="image_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/image_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/image_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/Link.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Link.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/Link.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,36 +1,31 @@
<?xml version="1.0"?>
-<type-info id="Link" kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Link</property>
- <property name="description" i18n:translate="">Link items are annotated URLs.</property>
- <property name="content_icon">link_icon.gif</property>
- <property name="content_meta_type">Link</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addLink</property>
- <property name="immediate_view">metadata_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="link_view"/>
- <alias from="view" to="link_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/link_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/link_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action action_id="metadata" title="Metadata"
- condition_expr=""
- url_expr="string:${object_url}/metadata_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+<object name="Link" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Link</property>
+ <property name="description"
+ i18n:translate="">Link items are annotated URLs.</property>
+ <property name="content_icon">link_icon.gif</property>
+ <property name="content_meta_type">Link</property>
+ <property name="product">CMFDefault</property>
+ <property name="factory">addLink</property>
+ <property name="immediate_view">metadata_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="link_view"/>
+ <alias from="view" to="link_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/link_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/link_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/News_Item.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,39 +1,33 @@
<?xml version="1.0"?>
-<type-info id="News Item"
- kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">News Item</property>
- <property name="description" i18n:translate="">News Items contain short text articles and carry a title as well as
-an optional description.</property>
- <property name="content_icon">newsitem_icon.gif</property>
- <property name="content_meta_type">News Item</property>
- <property name="product">CMFDefault</property>
- <property name="factory">addNewsItem</property>
- <property name="immediate_view">metadata_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types"></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="gethtml" to="source_html"/>
- <alias from="(Default)" to="newsitem_view"/>
- <alias from="view" to="newsitem_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/newsitem_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/newsitem_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action action_id="metadata" title="Metadata"
- condition_expr=""
- url_expr="string:${object_url}/metadata_edit_form"
- category="object" visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+<object name="News Item" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">News Item</property>
+ <property name="description"
+ i18n:translate="">News Items contain short text articles and carry a title as well as
+ an optional description.</property>
+ <property name="content_icon">newsitem_icon.gif</property>
+ <property name="content_meta_type">News Item</property>
+ <property name="product">CMFDefault</property>
+ <property name="factory">addNewsItem</property>
+ <property name="immediate_view">metadata_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="newsitem_view"/>
+ <alias from="gethtml" to="source_html"/>
+ <alias from="view" to="newsitem_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/newsitem_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/newsitem_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFDefault/profiles/default/types/Topic.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/types/Topic.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFDefault/profiles/default/types/Topic.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,54 +1,47 @@
<?xml version="1.0"?>
-<type-info id="Topic" kind="Factory-based Type Information"
- i18n:domain="cmf_default"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Topic</property>
- <property name="description" i18n:translate="">Topics are canned queries for organizing content with up to date queries into the catalog.</property>
- <property name="content_icon">topic_icon.gif</property>
- <property name="content_meta_type">Portal Topic</property>
- <property name="product">CMFTopic</property>
- <property name="factory">addTopic</property>
- <property name="immediate_view">topic_edit_form</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types">
- <element value="Topic" /></property>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="topic_view"/>
- <alias from="view" to="topic_view"/>
- </aliases>
- <action action_id="view" title="View" condition_expr=""
- url_expr="string:${object_url}/topic_view"
- category="object" visible="True">
- <permission>View</permission>
- </action>
- <action action_id="edit" title="Edit" condition_expr=""
- url_expr="string:${object_url}/topic_edit_form"
- category="object" visible="True">
- <permission>Change portal topics</permission>
- </action>
- <action action_id="criteria" title="Criteria"
- condition_expr=""
- url_expr="string:${object_url}/topic_criteria_form"
- category="object" visible="True">
- <permission>Change portal topics</permission>
- </action>
- <action action_id="folderContents" title="Subtopics"
- condition_expr=""
- url_expr="string:${object_url}/folder_contents"
- category="object" visible="True">
- <permission>List folder contents</permission>
- </action>
- <action action_id="new" title="New..." condition_expr=""
- url_expr="string:${object_url}/folder_factories"
- category="object" visible="False">
- <permission>Add portal topics</permission>
- </action>
- <action action_id="rename_items" title="Rename items"
- condition_expr=""
- url_expr="string:${object_url}/folder_rename_form"
- category="object" visible="False">
- <permission>Add portal topics</permission>
- </action>
-</type-info>
+<object name="Topic" meta_type="Factory-based Type Information"
+ i18n:domain="cmf_default" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Topic</property>
+ <property name="description"
+ i18n:translate="">Topics are canned queries for organizing content with up to date queries into the catalog.</property>
+ <property name="content_icon">topic_icon.gif</property>
+ <property name="content_meta_type">Portal Topic</property>
+ <property name="product">CMFTopic</property>
+ <property name="factory">addTopic</property>
+ <property name="immediate_view">topic_edit_form</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types">
+ <element value="Topic"/>
+ </property>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="topic_view"/>
+ <alias from="view" to="topic_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/topic_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/topic_edit_form" visible="True">
+ <permission value="Change portal topics"/>
+ </action>
+ <action title="Criteria" action_id="criteria" category="object"
+ condition_expr="" url_expr="string:${object_url}/topic_criteria_form"
+ visible="True">
+ <permission value="Change portal topics"/>
+ </action>
+ <action title="Subtopics" action_id="folderContents" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_contents"
+ visible="True">
+ <permission value="List folder contents"/>
+ </action>
+ <action title="New..." action_id="new" category="object" condition_expr=""
+ url_expr="string:${object_url}/folder_factories" visible="False">
+ <permission value="Add portal topics"/>
+ </action>
+ <action title="Rename items" action_id="rename_items" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_rename_form"
+ visible="False">
+ <permission value="Add portal topics"/>
+ </action>
+</object>
Modified: CMF/trunk/CMFSetup/tests/test_typeinfo.py
===================================================================
--- CMF/trunk/CMFSetup/tests/test_typeinfo.py 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFSetup/tests/test_typeinfo.py 2005-10-19 17:42:54 UTC (rev 39514)
@@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Unit tests for type information export import
+"""Types tool setup handler unit tests.
$Id$
"""
@@ -20,59 +20,54 @@
import Zope2
Zope2.startup()
+import Products
from OFS.Folder import Folder
-from OFS.SimpleItem import SimpleItem
+from Products.Five import zcml
+from zope.app.tests.placelesssetup import PlacelessSetup
-from Products.CMFCore.TypesTool import FactoryTypeInformation
-from Products.CMFCore.TypesTool import ScriptableTypeInformation
from Products.CMFCore.permissions import View
from Products.CMFCore.permissions import AccessContentsInformation
from Products.CMFCore.permissions import ModifyPortalContent
+from Products.CMFCore.TypesTool import FactoryTypeInformation
+from Products.CMFCore.TypesTool import ScriptableTypeInformation
+from Products.CMFCore.TypesTool import TypesTool
from common import BaseRegistryTests
from common import DummyExportContext
from common import DummyImportContext
-class DummyTypeInfo(SimpleItem):
+class _TypeInfoSetup(PlacelessSetup, BaseRegistryTests):
- pass
+ def _initSite(self, foo=0):
+ self.root.site = Folder(id='site')
+ site = self.root.site
+ ttool = site.portal_types = TypesTool()
+ if foo == 1:
+ fti = _TI_LIST[0].copy()
+ ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
+ sti = _TI_LIST[1].copy()
+ ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
+ elif foo == 2:
+ fti = _TI_LIST_WITH_FILENAME[0].copy()
+ ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
+ sti = _TI_LIST_WITH_FILENAME[1].copy()
+ ttool._setObject(sti['id'], ScriptableTypeInformation(**sti))
-class DummyTypesTool(Folder):
+ return site
- def __init__(self, type_infos):
+ def setUp(self):
+ PlacelessSetup.setUp(self)
+ BaseRegistryTests.setUp(self)
+ zcml.load_config('meta.zcml', Products.Five)
+ zcml.load_config('configure.zcml', Products.CMFCore)
- self._type_infos = type_infos
- for id, obj in [(x['id'], DummyTypeInfo(x))
- for x in type_infos]:
- self._setObject(id, obj)
+ def tearDown(self):
+ BaseRegistryTests.tearDown(self)
+ PlacelessSetup.tearDown(self)
- def listContentTypes(self):
- return [x['id'] for x in self._type_infos]
-
- def getTypeInfo(self, id):
-
- info = [x for x in self._type_infos if x['id'] == id]
- if len(info) == 0:
- raise KeyError, id
- info = info[0]
-
- if 'product' in info.keys():
- return FactoryTypeInformation(**info)
- else:
- return ScriptableTypeInformation(**info)
-
-class _TypeInfoSetup(BaseRegistryTests):
-
- def _initSite(self, type_infos=()):
-
- self.root.site = Folder(id='site')
- self.root.site.portal_types = DummyTypesTool(type_infos)
- return self.root.site
-
-
class TypesToolExportConfiguratorTests(_TypeInfoSetup):
def _getTargetClass(self):
@@ -87,9 +82,9 @@
self.assertEqual(len(configurator.listTypeInfo()), 0)
- def test_listTypeInfo_filled (self):
+ def test_listTypeInfo_filled(self):
- site = self._initSite(_TI_LIST)
+ site = self._initSite(1)
configurator = self._makeOne(site).__of__(site)
self.assertEqual(len(configurator.listTypeInfo()), len(_TI_LIST))
@@ -101,13 +96,13 @@
for i in range(len(_TI_LIST)):
found = info_list[i]
- expected = _TI_LIST[i]
+ expected = _TI_LIST[1-i]
self.assertEqual(found['id'], expected['id'])
self.failUnless(found.get('filename', _marker) is _marker)
def test_listTypeInfo_with_filename (self):
- site = self._initSite(_TI_LIST_WITH_FILENAME)
+ site = self._initSite(2)
configurator = self._makeOne(site).__of__(site)
info_list = configurator.listTypeInfo()
@@ -115,7 +110,7 @@
for i in range(len(_TI_LIST_WITH_FILENAME)):
found = info_list[i]
- expected = _TI_LIST_WITH_FILENAME[i]
+ expected = _TI_LIST_WITH_FILENAME[1-i]
self.assertEqual(found['id'], expected['id'])
self.assertEqual(found['filename'],
'types/%s.xml'
@@ -130,13 +125,13 @@
def test_generateXML_normal(self):
- site = self._initSite(_TI_LIST)
+ site = self._initSite(1)
configurator = self._makeOne(site).__of__(site)
self._compareDOM(configurator.generateXML(), _NORMAL_TOOL_EXPORT)
def test_generateXML_explicit_filename(self):
- site = self._initSite(_TI_LIST_WITH_FILENAME)
+ site = self._initSite(2)
configurator = self._makeOne(site).__of__(site)
self._compareDOM(configurator.generateXML(), _FILENAME_EXPORT)
@@ -164,10 +159,10 @@
tool_info = configurator.parseXML(_NORMAL_TOOL_EXPORT)
self.assertEqual(len(tool_info['types']), 2)
- type_info = tool_info['types'][0]
+ type_info = tool_info['types'][1]
self.assertEqual(type_info['id'], 'foo')
self.assertEqual(type_info['filename'], 'types/foo.xml')
- type_info = tool_info['types'][1]
+ type_info = tool_info['types'][0]
self.assertEqual(type_info['id'], 'bar')
self.assertEqual(type_info['filename'], 'types/bar.xml')
@@ -179,179 +174,14 @@
tool_info = configurator.parseXML(_FILENAME_EXPORT)
self.assertEqual(len(tool_info['types']), 2)
- type_info = tool_info['types'][0]
+ type_info = tool_info['types'][1]
self.assertEqual(type_info['id'], 'foo object')
self.assertEqual(type_info['filename'], 'types/foo_object.xml')
- type_info = tool_info['types'][1]
+ type_info = tool_info['types'][0]
self.assertEqual(type_info['id'], 'bar object')
self.assertEqual(type_info['filename'], 'types/bar_object.xml')
-class TypeInfoExportConfiguratorTests(_TypeInfoSetup):
-
- def _getTargetClass(self):
-
- from Products.CMFSetup.typeinfo import TypeInfoExportConfigurator
- return TypeInfoExportConfigurator
-
- def test_getTypeInfo_nonesuch(self):
-
- site = self._initSite(_TI_LIST)
- configurator = self._makeOne(site).__of__(site)
-
- self.assertRaises(ValueError, configurator.getTypeInfo, 'qux')
-
- def test_getTypeInfo_FTI(self):
-
- site = self._initSite(_TI_LIST)
- configurator = self._makeOne(site).__of__(site)
- found = configurator.getTypeInfo('foo')
- expected = _TI_LIST[0]
-
- self.assertEqual(found['meta_type'], 'Factory-based Type Information')
-
- for key in ('id', 'aliases'):
- self.assertEqual(found[key], expected[key])
-
- self.assertEqual(len(found['actions']), len(expected['actions']))
-
- for i in range(len(expected['actions'])):
-
- a_expected = expected['actions'][i]
- a_found = found['actions'][i]
-
- for k in ('id', 'action', 'permissions'):
- self.assertEqual(a_expected[k], a_found[k])
-
- for lk, rk in (('name', 'title'),):
- self.assertEqual(a_expected[lk], a_found[rk])
-
- def test_getTypeInfo_STI(self):
-
- site = self._initSite(_TI_LIST)
- configurator = self._makeOne(site).__of__(site)
- found = configurator.getTypeInfo('bar')
- expected = _TI_LIST[1]
-
- self.assertEqual(found['meta_type'], 'Scriptable Type Information')
-
- for key in ('id', 'aliases'):
- self.assertEqual(found[key], expected[key])
-
- self.assertEqual(len(found['actions']), len(expected['actions']))
-
- for i in range(len(expected['actions'])):
-
- a_expected = expected['actions'][i]
- a_found = found['actions'][i]
-
- for k in ('id', 'action', 'permissions'):
- self.assertEqual(a_expected[k], a_found[k])
-
- for lk, rk in (('name', 'title'),):
- self.assertEqual(a_expected[lk], a_found[rk])
-
- def test_generateXML_FTI(self):
-
- site = self._initSite(_TI_LIST)
- configurator = self._makeOne(site).__of__(site)
- self._compareDOM(configurator.generateXML(type_id='foo'),
- _FOO_EXPORT % 'foo')
-
- def test_generateXML_STI(self):
-
- site = self._initSite(_TI_LIST)
- configurator = self._makeOne(site).__of__(site)
- self._compareDOM(configurator.generateXML(type_id='bar'),
- _BAR_EXPORT % 'bar')
-
-
-class OldTypeInfoImportConfiguratorTests(_TypeInfoSetup):
-
- def _getTargetClass(self):
-
- from Products.CMFSetup.typeinfo import OldTypeInfoImportConfigurator
- return OldTypeInfoImportConfigurator
-
- def test_old_parseXML_FTI(self):
-
- site = self._initSite()
- tool = site.portal_types
- configurator = self._makeOne(site).__of__(site)
- self.assertEqual(len(tool.objectIds()), 0)
-
- info = configurator.parseXML(_FOO_OLD_EXPORT % 'foo')
-
- self.assertEqual(info['id'], 'foo')
- self.assertEqual(info['title'], 'Foo')
- self.assertEqual(len(info['aliases']), 2)
-
- def test_old_parseXML_STI(self):
-
- site = self._initSite()
- tool = site.portal_types
- configurator = self._makeOne(site).__of__(site)
- self.assertEqual(len(tool.objectIds()), 0)
-
- info = configurator.parseXML(_BAR_OLD_EXPORT % 'bar')
-
- self.assertEqual(info['id'], 'bar')
- self.assertEqual(info['title'], 'Bar')
- self.assertEqual(len(info['aliases']), 2)
-
-
-class TypeInfoImportConfiguratorTests(_TypeInfoSetup):
-
- def _getTargetClass(self):
-
- from Products.CMFSetup.typeinfo import TypeInfoImportConfigurator
- return TypeInfoImportConfigurator
-
- def test_parseXML_FTI(self):
-
- site = self._initSite()
- tool = site.portal_types
- configurator = self._makeOne(site).__of__(site)
- self.assertEqual(len(tool.objectIds()), 0)
-
- info = configurator.parseXML(_FOO_EXPORT % 'foo')
- props = dict([(e['id'], e) for e in info['properties']])
-
- self.assertEqual(info['id'], 'foo')
- self.assertEqual(props['title']['value'], 'Foo')
- self.assertEqual(len(info['aliases']), 2)
-
- def test_parseXML_STI(self):
-
- site = self._initSite()
- tool = site.portal_types
- configurator = self._makeOne(site).__of__(site)
- self.assertEqual(len(tool.objectIds()), 0)
-
- info = configurator.parseXML(_BAR_EXPORT % 'bar')
- props = dict([(e['id'], e) for e in info['properties']])
-
- self.assertEqual(info['id'], 'bar')
- self.assertEqual(props['title']['value'], 'Bar')
- self.assertEqual(len(info['aliases']), 2)
-
- def test_parseXML_actions(self):
-
- site = self._initSite()
- tool = site.portal_types
- configurator = self._makeOne(site).__of__(site)
-
- info = configurator.parseXML(_FOO_EXPORT % 'foo')
-
- action_info_list = info['actions']
- self.assertEqual(len(action_info_list), 3)
-
- action_info = action_info_list[0]
- self.assertEqual(action_info['id'], 'view')
- self.assertEqual(action_info['title'], 'View')
- self.assertEqual(action_info['permissions'], ('View',))
-
-
_TI_LIST = ({
'id': 'foo',
'title': 'Foo',
@@ -440,16 +270,16 @@
_NORMAL_TOOL_EXPORT = """\
<?xml version="1.0"?>
<types-tool>
- <type id="foo" />
<type id="bar" />
+ <type id="foo" />
</types-tool>
"""
_FILENAME_EXPORT = """\
<?xml version="1.0"?>
<types-tool>
- <type id="foo object" filename="types/foo_object.xml" />
<type id="bar object" filename="types/bar_object.xml" />
+ <type id="foo object" filename="types/foo_object.xml" />
</types-tool>
"""
@@ -461,6 +291,7 @@
"""
_FOO_OLD_EXPORT = """\
+<?xml version="1.0"?>
<type-info
id="%s"
kind="Factory-based Type Information"
@@ -509,57 +340,40 @@
"""
_FOO_EXPORT = """\
-<type-info
- i18n:domain="foo_domain"
- id="%s"
- kind="Factory-based Type Information"
- xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title" i18n:translate="">Foo</property>
- <property name="description" i18n:translate="">Foo things</property>
- <property name="content_icon">foo.png</property>
- <property name="content_meta_type">Foo Thing</property>
- <property name="product">CMFSetup</property>
- <property name="factory">addFoo</property>
- <property name="immediate_view">foo_view</property>
- <property name="global_allow">False</property>
- <property name="filter_content_types">False</property>
- <property name="allowed_content_types"/>
- <property name="allow_discussion">False</property>
- <aliases>
- <alias from="(Default)" to="foo_view" />
- <alias from="view" to="foo_view" />
- </aliases>
- <action
- action_id="view"
- title="View"
- url_expr="string:${object_url}/foo_view"
- condition_expr=""
- category="object"
- visible="True">
- <permission>View</permission>
- </action>
- <action
- action_id="edit"
- title="Edit"
- url_expr="string:${object_url}/foo_edit_form"
- condition_expr=""
- category="object"
- visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action
- action_id="metadata"
- title="Metadata"
- url_expr="string:${object_url}/metadata_edit_form"
- condition_expr=""
- category="object"
- visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+<?xml version="1.0"?>
+<object name="%s" meta_type="Factory-based Type Information"
+ i18n:domain="foo_domain" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ <property name="title" i18n:translate="">Foo</property>
+ <property name="description" i18n:translate="">Foo things</property>
+ <property name="content_icon">foo.png</property>
+ <property name="content_meta_type">Foo Thing</property>
+ <property name="product">CMFSetup</property>
+ <property name="factory">addFoo</property>
+ <property name="immediate_view">foo_view</property>
+ <property name="global_allow">False</property>
+ <property name="filter_content_types">False</property>
+ <property name="allowed_content_types"/>
+ <property name="allow_discussion">False</property>
+ <alias from="(Default)" to="foo_view"/>
+ <alias from="view" to="foo_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/foo_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/foo_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
"""
_BAR_OLD_EXPORT = """\
+<?xml version="1.0"?>
<type-info
id="%s"
kind="Scriptable Type Information"
@@ -618,82 +432,59 @@
"""
_BAR_EXPORT = """\
-<type-info
- id="%s"
- kind="Scriptable Type Information"
+<?xml version="1.0"?>
+<object name="%s" meta_type="Scriptable Type Information"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- <property name="title">Bar</property>
- <property name="description">Bar things</property>
- <property name="content_icon">bar.png</property>
- <property name="content_meta_type">Bar Thing</property>
- <property name="permission">Add portal content</property>
- <property name="constructor_path">make_bar</property>
- <property name="immediate_view">bar_view</property>
- <property name="global_allow">True</property>
- <property name="filter_content_types">True</property>
- <property name="allowed_content_types">
- <element value="foo"/></property>
- <property name="allow_discussion">True</property>
- <aliases>
- <alias from="(Default)" to="bar_view" />
- <alias from="view" to="bar_view" />
- </aliases>
- <action
- action_id="view"
- title="View"
- url_expr="string:${object_url}/bar_view"
- condition_expr=""
- category="object"
- visible="True">
- <permission>View</permission>
- </action>
- <action
- action_id="edit"
- title="Edit"
- url_expr="string:${object_url}/bar_edit_form"
- condition_expr=""
- category="object"
- visible="True">
- <permission>Modify portal content</permission>
- </action>
- <action
- action_id="contents"
- title="Contents"
- url_expr="string:${object_url}/folder_contents"
- condition_expr=""
- category="object"
- visible="True">
- <permission>Access contents information</permission>
- </action>
- <action
- action_id="metadata"
- title="Metadata"
- url_expr="string:${object_url}/metadata_edit_form"
- condition_expr=""
- category="object"
- visible="True">
- <permission>Modify portal content</permission>
- </action>
-</type-info>
+ <property name="title">Bar</property>
+ <property name="description">Bar things</property>
+ <property name="content_icon">bar.png</property>
+ <property name="content_meta_type">Bar Thing</property>
+ <property name="permission">Add portal content</property>
+ <property name="constructor_path">make_bar</property>
+ <property name="immediate_view">bar_view</property>
+ <property name="global_allow">True</property>
+ <property name="filter_content_types">True</property>
+ <property name="allowed_content_types">
+ <element value="foo"/>
+ </property>
+ <property name="allow_discussion">True</property>
+ <alias from="(Default)" to="bar_view"/>
+ <alias from="view" to="bar_view"/>
+ <action title="View" action_id="view" category="object" condition_expr=""
+ url_expr="string:${object_url}/bar_view" visible="True">
+ <permission value="View"/>
+ </action>
+ <action title="Edit" action_id="edit" category="object" condition_expr=""
+ url_expr="string:${object_url}/bar_edit_form" visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+ <action title="Contents" action_id="contents" category="object"
+ condition_expr="" url_expr="string:${object_url}/folder_contents"
+ visible="True">
+ <permission value="Access contents information"/>
+ </action>
+ <action title="Metadata" action_id="metadata" category="object"
+ condition_expr="" url_expr="string:${object_url}/metadata_edit_form"
+ visible="True">
+ <permission value="Modify portal content"/>
+ </action>
+</object>
"""
_UPDATE_FOO_IMPORT = """\
-<type-info id="foo">
- <aliases>
- <alias from="spam" to="eggs"/>
- </aliases>
-</type-info>
+<object name="foo">
+ <alias from="spam" to="eggs"/>
+</object>
"""
class Test_exportTypesTool(_TypeInfoSetup):
def test_empty(self):
+ from Products.CMFSetup.typeinfo import exportTypesTool
site = self._initSite()
context = DummyExportContext(site)
-
- from Products.CMFSetup.typeinfo import exportTypesTool
exportTypesTool(context)
self.assertEqual(len(context._wrote), 1)
@@ -703,36 +494,33 @@
self.assertEqual(content_type, 'text/xml')
def test_normal(self):
+ from Products.CMFSetup.typeinfo import exportTypesTool
- site = self._initSite(_TI_LIST)
+ site = self._initSite(1)
context = DummyExportContext(site)
-
- from Products.CMFSetup.typeinfo import exportTypesTool
exportTypesTool(context)
self.assertEqual(len(context._wrote), 3)
-
filename, text, content_type = context._wrote[0]
self.assertEqual(filename, 'typestool.xml')
self._compareDOM(text, _NORMAL_TOOL_EXPORT)
self.assertEqual(content_type, 'text/xml')
filename, text, content_type = context._wrote[1]
- self.assertEqual(filename, 'types/foo.xml')
- self._compareDOM(text, _FOO_EXPORT % 'foo')
+ self.assertEqual(filename, 'types/bar.xml')
+ self._compareDOM(text, _BAR_EXPORT % 'bar')
self.assertEqual(content_type, 'text/xml')
filename, text, content_type = context._wrote[2]
- self.assertEqual(filename, 'types/bar.xml')
- self._compareDOM(text, _BAR_EXPORT % 'bar')
+ self.assertEqual(filename, 'types/foo.xml')
+ self._compareDOM(text, _FOO_EXPORT % 'foo')
self.assertEqual(content_type, 'text/xml')
def test_with_filenames(self):
+ from Products.CMFSetup.typeinfo import exportTypesTool
- site = self._initSite(_TI_LIST_WITH_FILENAME)
+ site = self._initSite(2)
context = DummyExportContext(site)
-
- from Products.CMFSetup.typeinfo import exportTypesTool
exportTypesTool(context)
self.assertEqual(len(context._wrote), 3)
@@ -743,63 +531,61 @@
self.assertEqual(content_type, 'text/xml')
filename, text, content_type = context._wrote[1]
- self.assertEqual(filename, 'types/foo_object.xml')
- self._compareDOM(text, _FOO_EXPORT % 'foo object')
+ self.assertEqual(filename, 'types/bar_object.xml')
+ self._compareDOM(text, _BAR_EXPORT % 'bar object')
self.assertEqual(content_type, 'text/xml')
filename, text, content_type = context._wrote[2]
- self.assertEqual(filename, 'types/bar_object.xml')
- self._compareDOM(text, _BAR_EXPORT % 'bar object')
+ self.assertEqual(filename, 'types/foo_object.xml')
+ self._compareDOM(text, _FOO_EXPORT % 'foo object')
self.assertEqual(content_type, 'text/xml')
class Test_importTypesTool(_TypeInfoSetup):
def test_empty_default_purge(self):
+ from Products.CMFSetup.typeinfo import importTypesTool
- site = self._initSite(_TI_LIST)
+ site = self._initSite(1)
tool = site.portal_types
self.assertEqual(len(tool.objectIds()), 2)
context = DummyImportContext(site)
context._files['typestool.xml'] = _EMPTY_TOOL_EXPORT
-
- from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool(context)
self.assertEqual(len(tool.objectIds()), 0)
def test_empty_explicit_purge(self):
+ from Products.CMFSetup.typeinfo import importTypesTool
- site = self._initSite(_TI_LIST)
+ site = self._initSite(1)
tool = site.portal_types
self.assertEqual(len(tool.objectIds()), 2)
context = DummyImportContext(site, True)
context._files['typestool.xml'] = _EMPTY_TOOL_EXPORT
-
- from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool(context)
self.assertEqual(len(tool.objectIds()), 0)
def test_empty_skip_purge(self):
+ from Products.CMFSetup.typeinfo import importTypesTool
- site = self._initSite(_TI_LIST)
+ site = self._initSite(1)
tool = site.portal_types
self.assertEqual(len(tool.objectIds()), 2)
context = DummyImportContext(site, False)
context._files['typestool.xml'] = _EMPTY_TOOL_EXPORT
-
- from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool(context)
self.assertEqual(len(tool.objectIds()), 2)
def test_normal(self):
+ from Products.CMFSetup.typeinfo import importTypesTool
site = self._initSite()
tool = site.portal_types
@@ -810,8 +596,6 @@
context._files['typestool.xml'] = _NORMAL_TOOL_EXPORT
context._files['types/foo.xml'] = _FOO_EXPORT % 'foo'
context._files['types/bar.xml'] = _BAR_EXPORT % 'bar'
-
- from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool(context)
self.assertEqual(len(tool.objectIds()), 2)
@@ -819,6 +603,8 @@
self.failUnless('bar' in tool.objectIds())
def test_old_xml(self):
+ from Products.CMFSetup.typeinfo import exportTypesTool
+ from Products.CMFSetup.typeinfo import importTypesTool
site = self._initSite()
tool = site.portal_types
@@ -829,41 +615,45 @@
context._files['typestool.xml'] = _NORMAL_TOOL_EXPORT
context._files['types/foo.xml'] = _FOO_OLD_EXPORT % 'foo'
context._files['types/bar.xml'] = _BAR_OLD_EXPORT % 'bar'
-
- from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool(context)
self.assertEqual(len(tool.objectIds()), 2)
self.failUnless('foo' in tool.objectIds())
self.failUnless('bar' in tool.objectIds())
- def test_with_filenames_ascii(self):
+ context = DummyExportContext(site)
+ exportTypesTool(context)
+ filename, text, content_type = context._wrote[1]
+ self.assertEqual(filename, 'types/bar.xml')
+ self._compareDOM(text, _BAR_EXPORT % 'bar')
+ self.assertEqual(content_type, 'text/xml')
+
+ def test_with_filenames(self):
+ from Products.CMFSetup.typeinfo import importTypesTool
+
site = self._initSite()
tool = site.portal_types
self.assertEqual(len(tool.objectIds()), 0)
- context = DummyImportContext(site, encoding='ascii')
+ context = DummyImportContext(site)
context._files['typestool.xml'] = _FILENAME_EXPORT
context._files['types/foo_object.xml'] = _FOO_EXPORT % 'foo object'
context._files['types/bar_object.xml'] = _BAR_EXPORT % 'bar object'
-
- from Products.CMFSetup.typeinfo import importTypesTool
importTypesTool(context)
self.assertEqual(len(tool.objectIds()), 2)
self.failUnless('foo object' in tool.objectIds())
self.failUnless('bar object' in tool.objectIds())
- def test_fragment_skip_purge_ascii(self):
-
+ def test_normal_update(self):
from Products.CMFSetup.typeinfo import importTypesTool
site = self._initSite()
tool = site.portal_types
- context = DummyImportContext(site, encoding='ascii')
+ context = DummyImportContext(site)
context._files['typestool.xml'] = _NORMAL_TOOL_EXPORT
context._files['types/foo.xml'] = _FOO_EXPORT % 'foo'
context._files['types/bar.xml'] = _BAR_EXPORT % 'bar'
@@ -876,7 +666,7 @@
self.assertEqual(tool.foo._aliases,
{'(Default)': 'foo_view', 'view': 'foo_view'})
- context = DummyImportContext(site, False, encoding='ascii')
+ context = DummyImportContext(site, False)
context._files['typestool.xml'] = _UPDATE_TOOL_IMPORT
context._files['types/foo.xml'] = _UPDATE_FOO_IMPORT
importTypesTool(context)
@@ -893,9 +683,6 @@
return unittest.TestSuite((
unittest.makeSuite(TypesToolExportConfiguratorTests),
unittest.makeSuite(TypesToolImportConfiguratorTests),
- unittest.makeSuite(TypeInfoExportConfiguratorTests),
- unittest.makeSuite(TypeInfoImportConfiguratorTests),
- unittest.makeSuite(OldTypeInfoImportConfiguratorTests),
unittest.makeSuite(Test_exportTypesTool),
unittest.makeSuite(Test_importTypesTool),
))
Modified: CMF/trunk/CMFSetup/typeinfo.py
===================================================================
--- CMF/trunk/CMFSetup/typeinfo.py 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFSetup/typeinfo.py 2005-10-19 17:42:54 UTC (rev 39514)
@@ -15,135 +15,118 @@
$Id$
"""
+from xml.dom.minidom import parseString
+
import Products
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
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 _xmldir
from utils import ImportConfiguratorBase, ExportConfiguratorBase
from utils import CONVERTER, DEFAULT, KEY
+_FILENAME = 'typestool.xml'
-#
-# Entry points
-#
-_TOOL_FILENAME = 'typestool.xml'
-def importTypesTool( context ):
-
+def importTypesTool(context):
""" Import types tool and content types from XML files.
"""
site = context.getSite()
- encoding = context.getEncoding()
+ mode = context.shouldPurge() and PURGE or UPDATE
+ ttool = getToolByName(site, 'portal_types')
- types_tool = getToolByName( site, 'portal_types' )
-
if context.shouldPurge():
+ for type in ttool.objectIds():
+ ttool._delObject(type)
- for type in types_tool.objectIds():
- types_tool._delObject(type)
-
- ttc = TypesToolImportConfigurator( site, encoding )
- xml = context.readDataFile( _TOOL_FILENAME )
+ ttc = TypesToolImportConfigurator(site)
+ xml = context.readDataFile(_FILENAME)
if xml is None:
return 'Types tool: Nothing to import.'
- tool_info = ttc.parseXML( xml )
- tic = TypeInfoImportConfigurator( site, encoding )
- old_tic = OldTypeInfoImportConfigurator( site, encoding )
+ tool_info = ttc.parseXML(xml)
- for type_info in tool_info[ 'types' ]:
+ for type_info in tool_info['types']:
- filename = type_info[ 'filename' ]
- sep = filename.rfind( '/' )
+ filename = type_info['filename']
+ sep = filename.rfind('/')
if sep == -1:
- text = context.readDataFile( filename )
+ body = context.readDataFile( filename )
else:
- text = context.readDataFile( filename[sep+1:], filename[:sep] )
+ body = context.readDataFile( filename[sep+1:], filename[:sep] )
- is_old = '<description>' in text
- if is_old:
- info = old_tic.parseXML( text )
- else:
- info = tic.parseXML( text )
+ if body is None:
+ continue
- type_id = str(info['id'])
- if 'kind' in info:
+ root = parseString(body).documentElement
+ ti_id = str(root.getAttribute('name'))
+ if not ti_id:
+ # BBB: for CMF 1.5 profiles
+ # ID moved from 'id' to 'name'.
+ ti_id = str(root.getAttribute('id'))
+ if ti_id not in ttool.objectIds():
+ # BBB: for CMF 1.5 profiles
+ # 'kind' is now 'meta_type', the old 'meta_type' attribute
+ # was replaced by a property element.
+ meta_type = str(root.getAttribute('kind'))
+ if not meta_type:
+ meta_type = str(root.getAttribute('meta_type'))
for mt_info in Products.meta_types:
- if mt_info['name'] == info['kind']:
- type_info = mt_info['instance'](type_id)
+ if mt_info['name'] == meta_type:
+ ttool._setObject(ti_id, mt_info['instance'](ti_id))
break
else:
- raise ValueError('unknown kind \'%s\'' % info['kind'])
+ raise ValueError('unknown meta_type \'%s\'' % ti_id)
- if type_id in types_tool.objectIds():
- types_tool._delObject(type_id)
+ ti = ttool.getTypeInfo(ti_id)
+ importer = INodeImporter(ti, None)
+ if importer is None:
+ continue
- types_tool._setObject(type_id, type_info)
- type_info = types_tool._getOb(type_id)
- type_info._updateProperty('title', info['id'])
- type_info._updateProperty('content_meta_type', info['id'])
- type_info._updateProperty('content_icon', '%s.png' % info['id'])
- type_info._updateProperty('immediate_view',
- '%s_edit' % info['id'])
- else:
- type_info = types_tool._getOb(type_id)
+ importer.importNode(root, mode=mode)
- if is_old:
- type_info.manage_changeProperties(**info)
- else:
- for prop_info in info['properties']:
- tic.initProperty(type_info, prop_info)
-
- if 'i18n:domain' in info:
- type_info.i18n_domain = info['i18n:domain']
-
- if 'actions' in info:
- type_info._actions = info['actions']
-
- if 'aliases' in info:
- if not getattr(type_info, '_aliases', False):
- aliases = info['aliases']
- else:
- aliases = type_info.getMethodAliases()
- aliases.update(info['aliases'])
- type_info.setMethodAliases(aliases)
-
# XXX: YAGNI?
- # importScriptsToContainer(types_tool, ('typestool_scripts',),
+ # importScriptsToContainer(ttool, ('typestool_scripts',),
# context)
return 'Types tool imported.'
-def exportTypesTool( context ):
-
+def exportTypesTool(context):
""" Export types tool content types as a set of XML files.
"""
site = context.getSite()
- types_tool = getToolByName( site, 'portal_types' )
- ttc = TypesToolExportConfigurator( site ).__of__( site )
- tic = TypeInfoExportConfigurator( site ).__of__( site )
+ ttool = getToolByName(site, 'portal_types')
+ if ttool is None:
+ return 'Types tool: Nothing to export.'
+ ttc = TypesToolExportConfigurator(site).__of__(site)
tool_xml = ttc.generateXML()
- context.writeDataFile( _TOOL_FILENAME, tool_xml, 'text/xml' )
+ context.writeDataFile(_FILENAME, tool_xml, 'text/xml')
- for type_id in types_tool.listContentTypes():
+ for ti_id in ttool.listContentTypes():
+ type_filename = '%s.xml' % ti_id.replace( ' ', '_' )
+ ti = getattr(ttool, ti_id)
- type_filename = '%s.xml' % type_id.replace( ' ', '_' )
- type_xml = tic.generateXML( type_id=type_id )
- context.writeDataFile( type_filename
- , type_xml
- , 'text/xml'
- , 'types'
- )
+ exporter = INodeExporter(ti)
+ if exporter is None:
+ continue
+ doc = PrettyDocument()
+ doc.appendChild(exporter.exportNode(doc))
+ context.writeDataFile(type_filename, doc.toprettyxml(' '), 'text/xml',
+ 'types')
+
# XXX: YAGNI?
- # exportScriptsFromContainer(types_tool, ('typestool_scripts',))
+ # exportScriptsFromContainer(ttool, ('typestool_scripts',))
return 'Types tool exported'
@@ -206,157 +189,6 @@
InitializeClass(TypesToolExportConfigurator)
-# BBB: will be removed in CMF 1.7
-class TypesToolConfigurator(TypesToolImportConfigurator,
- TypesToolExportConfigurator):
- def __init__(self, site, encoding=None):
- TypesToolImportConfigurator.__init__(self, site, encoding)
- TypesToolExportConfigurator.__init__(self, site, encoding)
-
-InitializeClass(TypesToolConfigurator)
-
-
-# BBB: will be removed in CMF 1.7
-class OldTypeInfoImportConfigurator(ImportConfiguratorBase):
-
- def _getImportMapping(self):
-
- return {
- 'type-info':
- { 'id': {},
- 'kind': {},
- 'title': {},
- 'description': {CONVERTER: self._convertToUnique},
- 'meta_type': {KEY: 'content_meta_type'},
- 'icon': {KEY: 'content_icon'},
- 'immediate_view': {},
- 'global_allow': {CONVERTER: self._convertToBoolean},
- 'filter_content_types': {CONVERTER: self._convertToBoolean},
- 'allowed_content_type': {KEY: 'allowed_content_types'},
- 'allow_discussion': {CONVERTER: self._convertToBoolean},
- 'aliases': {CONVERTER: self._convertAliases},
- 'action': {KEY: 'actions'},
- 'product': {},
- 'factory': {},
- 'constructor_path': {},
- 'permission': {} },
- 'allowed_content_type':
- { '#text': {KEY: None} },
- 'aliases':
- { 'alias': {KEY: None} },
- 'alias':
- { 'from': {},
- 'to': {} },
- 'action':
- { 'action_id': {KEY: 'id'},
- 'title': {},
- 'description': {CONVERTER: self._convertToUnique},
- 'category': {},
- 'condition_expr': {KEY: 'condition'},
- 'permission': {KEY: 'permissions', DEFAULT: ()},
- 'visible': {CONVERTER: self._convertToBoolean},
- 'url_expr': {KEY: 'action'} },
- 'permission':
- { '#text': {KEY: None} } }
-
- def _convertAliases(self, val):
-
- result = {}
-
- for alias in val[0]:
- result[ alias['from'] ] = alias['to']
-
- return result
-
-InitializeClass(OldTypeInfoImportConfigurator)
-
-
-class TypeInfoImportConfigurator(ImportConfiguratorBase):
-
- def _getImportMapping(self):
-
- return {
- 'type-info':
- { 'i18n:domain': {},
- 'id': {},
- 'kind': {},
- 'aliases': {CONVERTER: self._convertAliases},
- 'action': {KEY: 'actions'},
- 'property': {KEY: 'properties', DEFAULT: ()},
- 'xmlns:i18n': {} },
- 'aliases':
- { 'alias': {KEY: None} },
- 'alias':
- { 'from': {},
- 'to': {} },
- 'action':
- { 'action_id': {KEY: 'id'},
- 'title': {},
- 'description': {CONVERTER: self._convertToUnique},
- 'category': {},
- 'condition_expr': {KEY: 'condition'},
- 'permission': {KEY: 'permissions', DEFAULT: ()},
- 'visible': {CONVERTER: self._convertToBoolean},
- 'url_expr': {KEY: 'action'} },
- 'permission':
- { '#text': {KEY: None} } }
-
- def _convertAliases(self, val):
-
- result = {}
-
- for alias in val[0]:
- result[ alias['from'] ] = alias['to']
-
- return result
-
-InitializeClass(TypeInfoImportConfigurator)
-
-
-class TypeInfoExportConfigurator(ExportConfiguratorBase):
-
- security = ClassSecurityInfo()
-
- security.declareProtected(ManagePortal, 'getTypeInfo')
- def getTypeInfo(self, type_id):
- """ Return a mapping for the given type info in the site.
-
- o These mappings are pretty much equivalent to the stock
- 'factory_type_information' elements used everywhere in the
- CMF.
- """
- ti = self._getTI(type_id)
- ti_info = self._extractObject(ti)
- ti_info['aliases'] = ti.getMethodAliases()
- ti_info['actions'] = [ ai.getMapping() for ai in ti.listActions() ]
- return ti_info
-
- security.declarePrivate('_getTI')
- def _getTI(self, type_id):
- """Get the TI from its id."""
- typestool = getToolByName(self._site, 'portal_types')
- try:
- return typestool.getTypeInfo(str(type_id)) # gTI expects ASCII?
- except KeyError:
- raise ValueError("Unknown type: %s" % type_id)
-
- def _getExportTemplate(self):
-
- return PageTemplateFile('ticTypeExport.xml', _xmldir)
-
-InitializeClass(TypeInfoExportConfigurator)
-
-
-# BBB: will be removed in CMF 1.7
-class TypeInfoConfigurator(TypeInfoImportConfigurator,
- TypeInfoExportConfigurator):
- def __init__(self, site, encoding=None):
- TypeInfoImportConfigurator.__init__(self, site, encoding)
- TypeInfoExportConfigurator.__init__(self, site, encoding)
-
-InitializeClass(TypeInfoConfigurator)
-
-
def _getTypeFilename( type_id ):
""" Return the name of the file which holds info for a given type.
Deleted: CMF/trunk/CMFSetup/xml/ticTypeExport.xml
===================================================================
--- CMF/trunk/CMFSetup/xml/ticTypeExport.xml 2005-10-19 13:51:51 UTC (rev 39513)
+++ CMF/trunk/CMFSetup/xml/ticTypeExport.xml 2005-10-19 17:42:54 UTC (rev 39514)
@@ -1,39 +0,0 @@
-<?xml version="1.0"?>
-<type-info xmlns:tal="http://xml.zope.org/namespaces/tal"
- id="foo"
- kind="Some Type Information"
- tal:define="type_id options/type_id;
- ti_info python: context.getTypeInfo(type_id)"
- tal:attributes="xmlns:i18n string:http://xml.zope.org/namespaces/i18n;
- i18n:domain ti_info/i18n_domain;
- id ti_info/id;
- kind ti_info/meta_type"
- ><tal:span tal:define="prop_infos ti_info/properties"
- tal:replace="structure python: context.generatePropertyNodes(prop_infos)"/>
- <aliases>
- <alias from="(Default)" to="foo_view"
- tal:repeat="item ti_info/aliases/items"
- tal:attributes="from python: item[ 0 ]; to python: item[ 1 ];"
- />
- </aliases>
- <action
- action_id="view"
- title="View"
- condition_expr=""
- url_expr="string:${object_url}/foo_view"
- category="object"
- visible="True"
- tal:repeat="action ti_info/actions"
- tal:attributes="action_id action/id;
- title action/title;
- condition_expr action/condition;
- url_expr action/action;
- category action/category;
- visible action/visible;
- "
- ><tal:case tal:condition="action/permissions">
- <permission
- tal:repeat="permission action/permissions"
- tal:content="permission">View</permission></tal:case>
- </action>
-</type-info>
More information about the CMF-checkins
mailing list