[Checkins] SVN: Products.CMF - Actions: Add a link_target attribute to store a value for the
Jens Vagelpohl
jens at dataflake.org
Sun May 24 05:10:11 EDT 2009
Log message for revision 100325:
- Actions: Add a link_target attribute to store a value for the
final rendered link tag's "target" attribute and use it.
(https://bugs.launchpad.net/zope-cmf/+bug/376951)
Changed:
U Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py
U Products.CMFCore/trunk/Products/CMFCore/ActionProviderBase.py
U Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
U Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
U Products.CMFCore/trunk/Products/CMFCore/dtml/editToolsActions.dtml
U Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_actions.py
U Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py
U Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionProviderBase.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py
U Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py
U Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt
U Products.CMFDefault/trunk/Products/CMFDefault/skins/ursine/main_template.pt
U Products.CMFDefault/trunk/Products/CMFDefault/skins/werebear/main_template.pt
U Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_generic/main_template.pt
U Products.CMFDefault/trunk/Products/CMFDefault/upgrade/configure.zcml
U Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to22.py
-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/ActionInformation.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -74,6 +74,7 @@
implements(IAction)
i18n_domain = 'cmf_default'
+ link_target = ''
security = ClassSecurityInfo()
@@ -92,6 +93,8 @@
'label': 'Condition (Expression)'},
{'id': 'permissions', 'type': 'multiple selection', 'mode': 'w',
'label': 'Permissions', 'select_variable': 'possible_permissions'},
+ {'id':'link_target', 'type': 'string', 'mode':'w',
+ 'label':'Link Target'},
{'id': 'visible', 'type': 'boolean', 'mode': 'w',
'label': 'Visible?'},
)
@@ -109,6 +112,7 @@
self._setPropValue( 'icon_expr', kw.get('icon_expr', '') )
self._setPropValue( 'available_expr', kw.get('available_expr', '') )
self._setPropValue( 'permissions', kw.get('permissions', () ) )
+ self._setPropValue( 'link_target', kw.get('link_target', '') )
self._setPropValue( 'visible', kw.get('visible', True) )
def _setPropValue(self, id, value):
@@ -177,6 +181,7 @@
self.data.setdefault( 'category', 'object' )
self.data.setdefault( 'visible', True )
self.data['available'] = True
+ self.data.setdefault('link_target', '')
else:
# if action isn't a dict, it has to implement IAction
(lazy_map, lazy_keys) = action.getInfoData()
@@ -263,6 +268,7 @@
, visible=True
, action=''
, icon_expr=''
+ , link_target=''
):
""" Set up an instance.
"""
@@ -276,6 +282,7 @@
, visible
, action
, icon_expr
+ , link_target
)
security.declarePrivate('edit')
@@ -290,6 +297,7 @@
, visible=_unchanged
, action=_unchanged
, icon_expr=_unchanged
+ , link_target=_unchanged
):
"""Edit the specified properties.
"""
@@ -322,6 +330,8 @@
if icon_expr and isinstance(icon_expr, basestring):
icon_expr = Expression(icon_expr)
self.setIconExpression(icon_expr)
+ if link_target is not _unchanged:
+ self.link_target = link_target
security.declareProtected( View, 'Title' )
def Title(self):
@@ -453,6 +463,12 @@
"""
return bool(self.visible)
+ security.declarePublic('getLinkTarget')
+ def getLinkTarget(self):
+ """ Return the rendered link tag's target attribute value
+ """
+ return self.link_target
+
security.declarePrivate('getMapping')
def getMapping(self):
""" Get a mapping of this object's data.
@@ -466,7 +482,8 @@
'permissions': self.permissions,
'visible': bool(self.visible),
'action': self.getActionExpression(),
- 'icon_expr' : self.getIconExpression() }
+ 'icon_expr' : self.getIconExpression(),
+ 'link_target' : self.getLinkTarget() }
security.declarePrivate('clone')
def clone( self ):
Modified: Products.CMFCore/trunk/Products/CMFCore/ActionProviderBase.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/ActionProviderBase.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/ActionProviderBase.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -182,6 +182,7 @@
, category
, visible=1
, icon_expr=''
+ , link_target=''
, REQUEST=None
):
""" Add an action to our list.
@@ -205,6 +206,7 @@
, visible=bool(visible)
, action=action
, icon_expr=icon_expr
+ , link_target=link_target
)
new_actions.append( new_action )
@@ -332,6 +334,7 @@
category = str( properties.get( 'category_%d' % index, '' ))
visible = bool( properties.get('visible_%d' % index, False) )
permissions = properties.get( 'permission_%d' % index, () )
+ link_target = str( properties.get( 'link_target_%d' % index, '' ) )
if not title:
raise ValueError('A title is required.')
@@ -350,6 +353,7 @@
, category=category
, visible=visible
, icon_expr=icon_expr
+ , link_target=link_target
)
def _getOAI(self, object):
Modified: Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt 2009-05-24 09:10:10 UTC (rev 100325)
@@ -4,6 +4,10 @@
2.2.0 (unreleased)
------------------
+- Actions: Add a link_target attribute to store a value for the
+ final rendered link tag's "target" attribute
+ (https://bugs.launchpad.net/zope-cmf/+bug/376951)
+
- MemberData tool: Make it easier to override the default
MemberData implementation by trying to look up a named
factory utility named "MemberData" before falling back on the
Modified: Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/TypesTool.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/TypesTool.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -99,6 +99,8 @@
_advanced_properties = (
{'id': 'add_view_expr', 'type': 'string', 'mode': 'w',
'label': 'Add view URL (Expression)'},
+ {'id': 'link_target', 'type': 'string', 'mode': 'w',
+ 'label': 'Add view link target'},
{'id':'immediate_view', 'type': 'string', 'mode':'w',
'label':'Initial view name'},
{'id':'global_allow', 'type': 'boolean', 'mode':'w',
@@ -128,6 +130,7 @@
allowed_content_types = ()
allow_discussion = False
global_allow = True
+ link_target = ''
def __init__(self, id, **kw):
@@ -161,6 +164,7 @@
, category=action.get('category', 'object')
, visible=action.get('visible', True)
, icon_expr=action.get('icon_expr', '')
+ , link_target=action.get('link_target', '')
)
self.setMethodAliases(kw.get('aliases', {}))
@@ -376,6 +380,7 @@
lazy_keys.append('icon')
else:
lazy_map['icon'] = ''
+ lazy_map['link_target'] = self.link_target
lazy_map['visible'] = True
lazy_map['available'] = self._checkAvailable
lazy_map['allowed'] = self._checkAllowed
Modified: Products.CMFCore/trunk/Products/CMFCore/dtml/editToolsActions.dtml
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/dtml/editToolsActions.dtml 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/dtml/editToolsActions.dtml 2009-05-24 09:10:10 UTC (rev 100325)
@@ -108,6 +108,21 @@
<td></td>
<td>
<div class="form-label">
+ Link target
+ </div>
+</td>
+<td>
+ <div class="form-element">
+ <input type="text" name="link_target_&dtml-index;" value="&dtml-link_target;" size="80"/>
+ </div>
+</td>
+</tr>
+
+
+<tr>
+<td></td>
+<td>
+ <div class="form-label">
Permission
</div>
</td>
@@ -262,6 +277,20 @@
<td></td>
<td>
<div class="form-label">
+ Link target
+ </div>
+</td>
+<td>
+ <div class="form-element">
+ <input type="text" name="link_target" value="" size="80" />
+ </div>
+</td>
+</tr>
+
+<tr>
+<td></td>
+<td>
+ <div class="form-label">
Permission
</div>
</td>
Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_actions.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_actions.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -43,6 +43,7 @@
<property name="icon_expr"></property>
<property name="available_expr">python:1</property>
<property name="permissions"/>
+ <property name="link_target"></property>
<property name="visible">True</property>
</object>
"""
@@ -57,6 +58,7 @@
<property name="icon_expr"></property>
<property name="available_expr"></property>
<property name="permissions"/>
+ <property name="link_target"></property>
<property name="visible">True</property>
</object>
</object>
@@ -76,6 +78,7 @@
<property name="icon_expr"></property>
<property name="available_expr"></property>
<property name="permissions"/>
+ <property name="link_target"></property>
<property name="visible">True</property>
</object>
</object>
@@ -156,6 +159,7 @@
<property name="icon_expr"></property>
<property name="available_expr">python:1</property>
<property name="permissions"></property>
+ <property name="link_target"></property>
<property name="visible">True</property>
</object>
</object>
@@ -176,6 +180,7 @@
<property name="icon_expr"></property>
<property name="available_expr">python:1</property>
<property name="permissions"></property>
+ <property name="link_target"></property>
<property name="visible">True</property>
</object>
</object>
Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -45,6 +45,7 @@
<property name="product"></property>
<property name="factory"></property>
<property name="add_view_expr"></property>
+ <property name="link_target"></property>
<property name="immediate_view"></property>
<property name="global_allow">True</property>
<property name="filter_content_types">True</property>
@@ -54,7 +55,7 @@
<alias from="view" to="foo"/>
<action title="Foo" action_id="foo_action" category="Bar"
condition_expr="python:1" icon_expr="string:${portal_url}/icon.png"
- url_expr="string:${object_url}/foo" visible="True"/>
+ link_target="" url_expr="string:${object_url}/foo" visible="True"/>
</object>
"""
@@ -77,6 +78,7 @@
'product': 'CMFSetup',
'factory': 'addFoo',
'add_view_expr': 'string:${folder_url}/foo_add_view',
+ 'link_target': '_new',
'immediate_view': 'foo_view',
'filter_content_types': False,
'allowed_content_types': (),
@@ -89,6 +91,7 @@
'title': 'View',
'action': 'string:${object_url}/foo_view',
'icon_expr': 'string:${portal_url}/preview_icon.png',
+ 'link_target': '_new',
'permissions': (View,),
},
{'id': 'edit',
@@ -114,6 +117,7 @@
'constructor_path': 'make_bar',
'permission': 'Add portal content',
'add_view_expr': 'string:${folder_url}/bar_add_view',
+ 'link_target': '',
'immediate_view': 'bar_view',
'filter_content_types': True,
'allowed_content_types': ('foo',),
@@ -196,6 +200,7 @@
<property name="product">CMFSetup</property>
<property name="factory">addFoo</property>
<property name="add_view_expr">string:${folder_url}/foo_add_view</property>
+ <property name="link_target">_new</property>
<property name="immediate_view">foo_view</property>
<property name="global_allow">False</property>
<property name="filter_content_types">False</property>
@@ -205,17 +210,20 @@
<alias from="view" to="foo_view"/>
<action title="View" action_id="view" category="object" condition_expr=""
url_expr="string:${object_url}/foo_view"
- icon_expr="string:${portal_url}/preview_icon.png" visible="True">
+ icon_expr="string:${portal_url}/preview_icon.png" link_target="_new"
+ visible="True">
<permission value="View"/>
</action>
<action title="Edit" action_id="edit" category="object" condition_expr=""
url_expr="string:${object_url}/foo_edit_form"
- icon_expr="string:${portal_url}/edit_icon.png" visible="True">
+ icon_expr="string:${portal_url}/edit_icon.png" link_target=""
+ 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"
- icon_expr="string:${portal_url}/metadata_icon.png" visible="True">
+ icon_expr="string:${portal_url}/metadata_icon.png" link_target=""
+ visible="True">
<permission value="Modify portal content"/>
</action>
</object>
@@ -233,6 +241,7 @@
<property name="permission">Add portal content</property>
<property name="constructor_path">make_bar</property>
<property name="add_view_expr">string:${folder_url}/bar_add_view</property>
+ <property name="link_target"/>
<property name="immediate_view">bar_view</property>
<property name="global_allow">True</property>
<property name="filter_content_types">True</property>
@@ -244,22 +253,22 @@
<alias from="view" to="bar_view"/>
<action title="View" action_id="view" category="object" condition_expr=""
url_expr="string:${object_url}/bar_view"
- icon_expr="" visible="True">
+ icon_expr="" link_target="" visible="True">
<permission value="View"/>
</action>
<action title="Edit" action_id="edit" category="object" condition_expr=""
url_expr="string:${object_url}/bar_edit_form"
- icon_expr="" visible="True">
+ icon_expr="" link_target="" 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"
- icon_expr="" visible="True">
+ icon_expr="" link_target="" 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"
- icon_expr="" visible="True">
+ icon_expr="" link_target="" visible="True">
<permission value="Modify portal content"/>
</action>
</object>
Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/typeinfo.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -102,6 +102,7 @@
child.setAttribute('condition_expr', ai_info['condition'])
child.setAttribute('url_expr', ai_info['action'])
child.setAttribute('icon_expr', ai_info['icon_expr'])
+ child.setAttribute('link_target', ai_info['link_target'])
child.setAttribute('visible', str(bool(ai_info['visible'])))
for permission in ai_info['permissions']:
sub = self._doc.createElement('permission')
@@ -123,6 +124,10 @@
condition = str(child.getAttribute('condition_expr'))
action = str(child.getAttribute('url_expr'))
icon_expr = str(child.getAttribute('icon_expr'))
+ if child.hasAttribute('link_target'):
+ link_target = str(child.getAttribute('link_target'))
+ else:
+ link_target = ''
visible = self._convertToBoolean(child.getAttribute('visible'))
remove = child.hasAttribute('remove') and True or False
permissions = []
@@ -143,12 +148,13 @@
if action_obj is None:
self.context.addAction(id, title, action, condition,
tuple(permissions), category, visible,
- icon_expr=icon_expr)
+ icon_expr=icon_expr,
+ link_target=link_target)
else:
action_obj.edit(title=title, action=action,
icon_expr=icon_expr, condition=condition,
permissions=tuple(permissions),
- visible=visible)
+ visible=visible, link_target=link_target)
class TypesToolXMLAdapter(XMLAdapterBase, ObjectManagerHelpers,
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionInformation.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -72,7 +72,7 @@
def test_getInfoData_empty(self):
WANTED = ( {'available': True, 'category': '', 'description': '',
'id': 'foo', 'icon': '', 'permissions': (), 'title': '',
- 'url': '', 'visible': True}, [] )
+ 'url': '', 'visible': True, 'link_target': ''}, [] )
a = self._makeOne('foo')
self.assertEqual( a.getInfoData(), WANTED )
@@ -84,12 +84,14 @@
icon_expr='string:foo_icon',
available_expr='',
permissions=('View',),
- visible=False)
+ visible=False,
+ link_target='_top')
WANTED = ( {'available': True, 'category': '',
'description': 'Foo description.',
'id': 'foo', 'icon': a.icon_expr_object,
'permissions': ('View',), 'title': 'Foo Title',
- 'url': a.url_expr_object, 'visible': False},
+ 'url': a.url_expr_object, 'visible': False,
+ 'link_target': a.link_target },
['url', 'icon'] )
self.assertEqual( a.getInfoData(), WANTED )
@@ -146,7 +148,7 @@
WANTED = {'allowed': True, 'available': True, 'category': '',
'description': '', 'icon': '', 'id': 'foo', 'title': '',
- 'url': '', 'visible': True}
+ 'url': '', 'visible': True, 'link_target': ''}
action = Action(id='foo')
ec = None
@@ -167,7 +169,7 @@
WANTED = {'allowed': True, 'available': True, 'category': 'object',
'description': '', 'id': 'foo', 'title': 'foo', 'url': '',
- 'visible': True, 'icon': ''}
+ 'visible': True, 'icon': '', 'link_target': ''}
action = ActionInformation(id='foo')
ec = None
@@ -187,7 +189,7 @@
def test_create_from_dict(self):
WANTED = {'allowed': True, 'available': True, 'category': 'object',
'id': 'foo', 'title': 'foo', 'url': '', 'visible': True,
- 'icon': '' }
+ 'icon': '' , 'link_target': ''}
action = {'name': 'foo', 'url': ''}
ec = None
@@ -219,7 +221,7 @@
def test_create_from_dict(self):
WANTED = {'allowed': True, 'available': True, 'category': 'object',
'id': 'foo', 'title': 'foo', 'url': '', 'visible': True,
- 'icon': ''}
+ 'icon': '', 'link_target': ''}
action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
ec = createExprContext(self.site, self.site, None)
@@ -423,7 +425,8 @@
def test_getInfoData_empty(self):
WANTED = ( {'available': True, 'category': 'object',
'description': '', 'id': 'foo', 'permissions': (),
- 'title': 'foo', 'url': '', 'visible': True, 'icon': ''},[])
+ 'title': 'foo', 'url': '', 'visible': True, 'icon': '',
+ 'link_target': ''},[])
a = self._makeOne('foo')
self.assertEqual( a.getInfoData(), WANTED )
@@ -435,12 +438,14 @@
icon_expr='string:${object_url}/icon.gif',
condition='',
permissions=('View',),
- visible=False)
+ visible=False,
+ link_target='_top')
WANTED = ( {'available': True, 'category': 'object',
'description': 'Foo description.', 'id': 'foo',
'permissions': ('View',), 'title': 'Foo Title',
'url': a._getActionObject(), 'visible': False,
- 'icon': a._getIconExpressionObject(), },
+ 'icon': a._getIconExpressionObject(),
+ 'link_target': a.link_target },
['url', 'icon'] )
self.assertEqual( a.getInfoData(), WANTED )
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionProviderBase.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionProviderBase.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionProviderBase.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -242,7 +242,8 @@
def test_listActionInfos(self):
wanted = [{'id': 'an_id', 'title': 'A Title', 'description': '',
'url': '', 'category': 'object', 'visible': False,
- 'available': True, 'allowed': True, 'icon': ''}]
+ 'available': True, 'allowed': True, 'link_target': '',
+ 'icon': ''}]
apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
rval = apb.listActionInfos()
@@ -263,7 +264,8 @@
def test_getActionInfo(self):
wanted = {'id': 'an_id', 'title': 'A Title', 'description': '',
'url': '', 'category': 'object', 'visible': False,
- 'available': True, 'allowed': True, 'icon': ''}
+ 'available': True, 'allowed': True, 'link_target': '',
+ 'icon': ''}
apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
rval = apb.getActionInfo( ('object/an_id',) )
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_ActionsTool.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -153,6 +153,7 @@
'folder is not object'),
permissions=('List folder contents',),
category='folder',
+ link_target='_top',
visible=1)
,
)
@@ -168,7 +169,8 @@
'visible': True,
'available': True,
'allowed': True,
- 'category': 'folder'}],
+ 'category': 'folder',
+ 'link_target': '_top'}],
'global': []})
def tearDown(self):
Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -298,12 +298,13 @@
'content_meta_type': 'Foo Content',
'factory' : 'cmf.foo',
'icon_expr' : 'string:${portal_url}/foo_icon_expr.gif',
- 'add_view_expr': 'string:${folder_url}/foo_add_view'}
+ 'add_view_expr': 'string:${folder_url}/foo_add_view',
+ 'link_target': '_new'}
ti = self._makeInstance(**ti_data)
info_data = ti.getInfoData()
self.assertEqual(len(info_data), 2)
- self.assertEqual(len(info_data[0]), 9)
+ self.assertEqual(len(info_data[0]), 10)
self.assertEqual(info_data[0]['id'], ti_data['id'])
self.assertEqual(info_data[0]['category'], 'folder/add')
self.assertEqual(info_data[0]['title'], ti_data['title'])
@@ -315,6 +316,7 @@
self.assertEqual(info_data[0]['visible'], True)
self.assertEqual(info_data[0]['available'], ti._checkAvailable)
self.assertEqual(info_data[0]['allowed'], ti._checkAllowed)
+ self.assertEqual(info_data[0]['link_target'], ti.link_target)
self.assertEqual(set(info_data[1]),
set(['url', 'icon', 'available', 'allowed']))
@@ -329,7 +331,7 @@
info_data = ti.getInfoData()
self.assertEqual(len(info_data), 2)
- self.assertEqual(len(info_data[0]), 9)
+ self.assertEqual(len(info_data[0]), 10)
self.assertEqual(info_data[0]['id'], ti_data['id'])
self.assertEqual(info_data[0]['category'], 'folder/add')
self.assertEqual(info_data[0]['title'], ti_data['title'])
@@ -339,6 +341,7 @@
self.assertEqual(info_data[0]['visible'], True)
self.assertEqual(info_data[0]['available'], ti._checkAvailable)
self.assertEqual(info_data[0]['allowed'], ti._checkAllowed)
+ self.assertEqual(info_data[0]['link_target'], '')
self.assertEqual(set(info_data[1]), set(['available', 'allowed']))
Modified: Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFDefault/trunk/Products/CMFDefault/CHANGES.txt 2009-05-24 09:10:10 UTC (rev 100325)
@@ -4,6 +4,10 @@
2.2.0 (unreleased)
------------------
+- Actions: Utilize the new link_target attribute for the
+ final rendered link tag's "target" attribute
+ (https://bugs.launchpad.net/zope-cmf/+bug/376951)
+
- MembershipTool: Support members folder paths to folders deeper in
the portal folder hierarchy by allowing to specify either a
simple name (as before), or a relative path within the portal
Modified: Products.CMFDefault/trunk/Products/CMFDefault/skins/ursine/main_template.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/skins/ursine/main_template.pt 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFDefault/trunk/Products/CMFDefault/skins/ursine/main_template.pt 2009-05-24 09:10:10 UTC (rev 100325)
@@ -52,7 +52,8 @@
<ul id="object_actions_menu">
<li tal:repeat="action globals/object_actions">
<a href="#object_action"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">OBJECT ACTION_TITLE</a><br />
</li>
@@ -61,7 +62,8 @@
<ul id="workflow_actions_menu">
<li tal:repeat="action globals/workflow_actions">
<a href="#workflow_action"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">OBJECT ACTION_TITLE</a><br />
</li>
@@ -70,7 +72,8 @@
<ul id="folder_actions_menu">
<li tal:repeat="action globals/folder_actions">
<a href="#folder_action"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">FOLDER ACTION_TITLE</a><br />
</li>
@@ -79,7 +82,8 @@
<ul id="add_actions_menu">
<li tal:repeat="action globals/add_actions">
<a href="#add_action"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">ADD ACTION_TITLE</a><br />
</li>
@@ -88,7 +92,8 @@
<ul id="user_actions_menu">
<li tal:repeat="action globals/user_actions">
<a href="#user_action"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title" i18n:translate="">USER ACTION TITLE</a>
</li>
</ul>
@@ -96,7 +101,8 @@
<ul id="global_actions_menu">
<li tal:repeat="action globals/global_actions">
<a href="#global_action"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title" i18n:translate="">GLOBAL ACTION TITLE</a>
</li>
</ul>
Modified: Products.CMFDefault/trunk/Products/CMFDefault/skins/werebear/main_template.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/skins/werebear/main_template.pt 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFDefault/trunk/Products/CMFDefault/skins/werebear/main_template.pt 2009-05-24 09:10:10 UTC (rev 100325)
@@ -97,7 +97,8 @@
tal:attributes="src icon_url;
alt action/title;
title action/title"/>
- <a href="" tal:attributes="href action/url"
+ <a href="" tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title" i18n:translate="">Login</a
><tal:span tal:condition="not: repeat/action/end"> |</tal:span></tal:span>
<tal:span tal:condition="nothing"
@@ -160,7 +161,8 @@
alt action/title;
title action/title"/>
<a href=""
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">View</a><br />
</span>
@@ -197,7 +199,8 @@
alt action/title;
title action/title"/>
<a href="content_submit_form"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Submit</a><br />
</span>
@@ -216,7 +219,8 @@
alt action/title;
title action/title"/>
<a href="../folder_contents"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Folder contents</a><br />
</span>
@@ -240,7 +244,8 @@
alt action/title;
title action/title"/>
<a href="+Document"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Document</a><br />
</span>
@@ -259,7 +264,8 @@
alt action/title;
title action/title"/>
<a href="undo_form"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Undo</a><br />
</span>
Modified: Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_generic/main_template.pt
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_generic/main_template.pt 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFDefault/trunk/Products/CMFDefault/skins/zpt_generic/main_template.pt 2009-05-24 09:10:10 UTC (rev 100325)
@@ -124,7 +124,8 @@
tal:attributes="src icon_url;
alt action/title;
title action/title"/>
- <a href="" tal:attributes="href action/url"
+ <a href="" tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title" i18n:translate="">Login</a
><tal:span tal:condition="not: repeat/action/end"> |</tal:span></tal:span>
<tal:span tal:condition="nothing"
@@ -188,7 +189,8 @@
alt action/title;
title action/title"/>
<a href=""
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">View</a><br />
</span>
@@ -226,7 +228,8 @@
alt action/title;
title action/title"/>
<a href="content_submit_form"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Submit</a><br />
</span>
@@ -246,7 +249,8 @@
alt action/title;
title action/title"/>
<a href="../folder_contents"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Folder contents</a><br />
</span>
@@ -271,7 +275,8 @@
alt action/title;
title action/title"/>
<a href="+Document"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Document</a><br />
</span>
@@ -291,7 +296,8 @@
alt action/title;
title action/title"/>
<a href="undo_form"
- tal:attributes="href action/url"
+ tal:attributes="href action/url;
+ target action/link_target|nothing"
tal:content="action/title"
i18n:translate="">Undo</a><br />
</span>
Modified: Products.CMFDefault/trunk/Products/CMFDefault/upgrade/configure.zcml
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/upgrade/configure.zcml 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFDefault/trunk/Products/CMFDefault/upgrade/configure.zcml 2009-05-24 09:10:10 UTC (rev 100325)
@@ -83,6 +83,12 @@
checker=".to22.check_action_icons"
/>
+ <genericsetup:upgradeStep
+ title="Add action link target"
+ handler=".to22.add_action_linktargets"
+ checker=".to22.check_action_linktargets"
+ />
+
</genericsetup:upgradeSteps>
<genericsetup:upgradeStep
Modified: Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to22.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to22.py 2009-05-24 08:55:49 UTC (rev 100324)
+++ Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to22.py 2009-05-24 09:10:10 UTC (rev 100325)
@@ -17,6 +17,7 @@
import logging
from urllib import quote
+from Acquisition import aq_base
from Acquisition import aq_inner
from Acquisition import aq_parent
from zope.component.interfaces import ComponentLookupError
@@ -124,3 +125,49 @@
changed = True
if changed:
logger.info("TypeInfo '%s' changed." % ti.getId())
+
+def check_action_linktargets(tool):
+ """2.1.x to 2.2.0 upgrade step checker
+ """
+ # Actions in portal_actions tool
+ atool = getToolByName(tool, 'portal_actions')
+ for ai in atool.listActions():
+ if getattr(aq_base(ai), 'link_target', None) is None:
+ return True
+
+ # Actions from TypeInformation objects
+ ttool = getToolByName(tool, 'portal_types')
+ for ti in ttool.listTypeInfo():
+ if getattr(aq_base(ti), 'link_target', None) is None:
+ return True
+
+ for ai in ti.listActions():
+ if getattr(aq_base(ai), 'link_target', None) is None:
+ return True
+ return False
+
+def add_action_linktargets(tool):
+ """2.1.x to 2.2.0 upgrade step handler
+ """
+ logger = logging.getLogger('GenericSetup.upgrade')
+
+ # Actions in portal_actions tool
+ atool = getToolByName(tool, 'portal_actions')
+ for ai in atool.listActions():
+ if getattr(aq_base(ai), 'link_target', None) is None:
+ ai.link_target = ''
+ logger.info('Action "%s" changed.' % ai.getId())
+
+ # Actions from TypeInformation objects
+ ttool = getToolByName(tool, 'portal_types')
+ for ti in ttool.listTypeInfo():
+ if getattr(aq_base(ti), 'link_target', None) is None:
+ ti.link_target = ''
+ logger.info("TypeInfo '%s' changed." % ti.getId())
+
+ for ai in ti.listActions():
+ if getattr(aq_base(ai), 'link_target', None) is None:
+ ai.link_target = ''
+ msg = 'TypeInfo "%s" action "%s" changed.'
+ logger.info(msg % (ti.getId(), ai.getId()))
+
More information about the Checkins
mailing list