[Checkins] SVN: Products.CMFCore/branches/2.2/Products/CMFCore/ - return None if 'link_target' is an empty string
Yvo Schubbe
y.2010 at wcm-solutions.de
Mon Mar 1 03:30:31 EST 2010
Log message for revision 109533:
- return None if 'link_target' is an empty string
Changed:
U Products.CMFCore/branches/2.2/Products/CMFCore/ActionInformation.py
U Products.CMFCore/branches/2.2/Products/CMFCore/CHANGES.txt
U Products.CMFCore/branches/2.2/Products/CMFCore/TypesTool.py
U Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionInformation.py
U Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionProviderBase.py
U Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_TypesTool.py
-=-
Modified: Products.CMFCore/branches/2.2/Products/CMFCore/ActionInformation.py
===================================================================
--- Products.CMFCore/branches/2.2/Products/CMFCore/ActionInformation.py 2010-03-01 02:12:57 UTC (rev 109532)
+++ Products.CMFCore/branches/2.2/Products/CMFCore/ActionInformation.py 2010-03-01 08:30:30 UTC (rev 109533)
@@ -149,6 +149,8 @@
val = True
elif id == 'i18n_domain':
continue
+ elif id == 'link_target':
+ val = val or None
elif self.i18n_domain and id in ('title', 'description'):
val = Message(val, self.i18n_domain)
lazy_map[id] = val
@@ -177,7 +179,7 @@
self.data.setdefault( 'title', self.data['name'] )
del self.data['name']
self.data.setdefault( 'url', '' )
- self.data.setdefault( 'link_target', '' )
+ self.data.setdefault( 'link_target', None )
self.data.setdefault( 'icon', '' )
self.data.setdefault( 'category', 'object' )
self.data.setdefault( 'visible', True )
@@ -500,6 +502,9 @@
lazy_keys = []
lazy_map = self.getMapping()
+ if not lazy_map['link_target']:
+ lazy_map['link_target'] = None
+
if lazy_map['action']:
lazy_map['url'] = self._getActionObject()
lazy_keys.append('url')
Modified: Products.CMFCore/branches/2.2/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/branches/2.2/Products/CMFCore/CHANGES.txt 2010-03-01 02:12:57 UTC (rev 109532)
+++ Products.CMFCore/branches/2.2/Products/CMFCore/CHANGES.txt 2010-03-01 08:30:30 UTC (rev 109533)
@@ -4,7 +4,10 @@
2.2.1-beta (unreleased)
-----------------------
+- Actions: Return None if 'link_target' is an empty string.
+ This helps to avoid invalid empty 'target' attributes in HTML output.
+
2.2.0 (2010-01-04)
------------------
Modified: Products.CMFCore/branches/2.2/Products/CMFCore/TypesTool.py
===================================================================
--- Products.CMFCore/branches/2.2/Products/CMFCore/TypesTool.py 2010-03-01 02:12:57 UTC (rev 109532)
+++ Products.CMFCore/branches/2.2/Products/CMFCore/TypesTool.py 2010-03-01 08:30:30 UTC (rev 109533)
@@ -396,7 +396,7 @@
lazy_keys.append('icon')
else:
lazy_map['icon'] = ''
- lazy_map['link_target'] = self.link_target
+ lazy_map['link_target'] = self.link_target or None
lazy_map['visible'] = True
lazy_map['available'] = self._checkAvailable
lazy_map['allowed'] = self._checkAllowed
Modified: Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionInformation.py
===================================================================
--- Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionInformation.py 2010-03-01 02:12:57 UTC (rev 109532)
+++ Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionInformation.py 2010-03-01 08:30:30 UTC (rev 109533)
@@ -72,7 +72,7 @@
def test_getInfoData_empty(self):
WANTED = ( {'available': True, 'category': '', 'description': '',
'id': 'foo', 'icon': '', 'permissions': (), 'title': '',
- 'url': '', 'visible': True, 'link_target': ''}, [] )
+ 'url': '', 'visible': True, 'link_target': None}, [] )
a = self._makeOne('foo')
self.assertEqual( a.getInfoData(), WANTED )
@@ -148,7 +148,7 @@
WANTED = {'allowed': True, 'available': True, 'category': '',
'description': '', 'icon': '', 'id': 'foo', 'title': '',
- 'url': '', 'visible': True, 'link_target': ''}
+ 'url': '', 'visible': True, 'link_target': None}
action = Action(id='foo')
ec = None
@@ -169,7 +169,7 @@
WANTED = {'allowed': True, 'available': True, 'category': 'object',
'description': '', 'id': 'foo', 'title': 'foo', 'url': '',
- 'visible': True, 'icon': '', 'link_target': ''}
+ 'visible': True, 'icon': '', 'link_target': None}
action = ActionInformation(id='foo')
ec = None
@@ -189,7 +189,7 @@
def test_create_from_dict(self):
WANTED = {'allowed': True, 'available': True, 'category': 'object',
'id': 'foo', 'title': 'foo', 'url': '', 'visible': True,
- 'icon': '' , 'link_target': ''}
+ 'icon': '' , 'link_target': None}
action = {'name': 'foo', 'url': ''}
ec = None
@@ -221,7 +221,7 @@
def test_create_from_dict(self):
WANTED = {'allowed': True, 'available': True, 'category': 'object',
'id': 'foo', 'title': 'foo', 'url': '', 'visible': True,
- 'icon': '', 'link_target': ''}
+ 'icon': '', 'link_target': None}
action = {'name': 'foo', 'url': '', 'permissions': ('View',)}
ec = createExprContext(self.site, self.site, None)
@@ -426,7 +426,7 @@
WANTED = ( {'available': True, 'category': 'object',
'description': '', 'id': 'foo', 'permissions': (),
'title': 'foo', 'url': '', 'visible': True, 'icon': '',
- 'link_target': ''},[])
+ 'link_target': None},[])
a = self._makeOne('foo')
self.assertEqual( a.getInfoData(), WANTED )
Modified: Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionProviderBase.py
===================================================================
--- Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionProviderBase.py 2010-03-01 02:12:57 UTC (rev 109532)
+++ Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_ActionProviderBase.py 2010-03-01 08:30:30 UTC (rev 109533)
@@ -242,7 +242,7 @@
def test_listActionInfos(self):
wanted = [{'id': 'an_id', 'title': 'A Title', 'description': '',
'url': '', 'category': 'object', 'visible': False,
- 'available': True, 'allowed': True, 'link_target': '',
+ 'available': True, 'allowed': True, 'link_target': None,
'icon': ''}]
apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
@@ -264,7 +264,7 @@
def test_getActionInfo(self):
wanted = {'id': 'an_id', 'title': 'A Title', 'description': '',
'url': '', 'category': 'object', 'visible': False,
- 'available': True, 'allowed': True, 'link_target': '',
+ 'available': True, 'allowed': True, 'link_target': None,
'icon': ''}
apb = self.site._setObject( 'portal_apb', self._makeProvider(1) )
Modified: Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_TypesTool.py
===================================================================
--- Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_TypesTool.py 2010-03-01 02:12:57 UTC (rev 109532)
+++ Products.CMFCore/branches/2.2/Products/CMFCore/tests/test_TypesTool.py 2010-03-01 08:30:30 UTC (rev 109533)
@@ -430,7 +430,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(info_data[0]['link_target'], None)
self.assertEqual(set(info_data[1]), set(['available', 'allowed']))
More information about the checkins
mailing list