[z3-checkins] r25706 - z3/CMFonFive/trunk
regebro at codespeak.net
regebro at codespeak.net
Tue Apr 11 20:25:57 CEST 2006
Author: regebro
Date: Tue Apr 11 20:25:57 2006
New Revision: 25706
Modified:
z3/CMFonFive/trunk/CHANGES.txt
z3/CMFonFive/trunk/fiveactionstool.py
z3/CMFonFive/trunk/version.txt
Log:
The generated id of the icons is now consistent.
Modified: z3/CMFonFive/trunk/CHANGES.txt
==============================================================================
--- z3/CMFonFive/trunk/CHANGES.txt (original)
+++ z3/CMFonFive/trunk/CHANGES.txt Tue Apr 11 20:25:57 2006
@@ -1,7 +1,17 @@
CMFonFive Product Changelog
+ CMFonFive 1.3.3 (2005-04-11)
+
+ - The id of the action is now generated from the last part of the interface
+ the menu item is defined for, and the last part of the action. This should
+ generate enough uniqueness so that action id's does not clash too much, while
+ never generating two different ids.
+
+ The reason for this change is that it enables you to add icons with the CMF
+ ActionIconsTool.
+
CMFonFive 1.3.2 (2005-02-22)
-
+
- GenericSetup calls all action providers with both object and info
as None, which resulted in an attribute error.
Modified: z3/CMFonFive/trunk/fiveactionstool.py
==============================================================================
--- z3/CMFonFive/trunk/fiveactionstool.py (original)
+++ z3/CMFonFive/trunk/fiveactionstool.py Tue Apr 11 20:25:57 2006
@@ -21,13 +21,52 @@
from Products.CMFCore.Expression import Expression
from Products.CMFCore.utils import UniqueObject
+from zope.interface import providedBy
from zope.app import zapi
from zope.app.publisher.interfaces.browser import IBrowserMenu
-from zope.app.publisher.browser.menu import getMenu
-
+from zope.app.publisher.interfaces.browser import IBrowserSubMenuItem
+from zope.security.proxy import removeSecurityProxy
+
def _listMenuIds():
return [id for id, utility in zapi.getUtilitiesFor(IBrowserMenu)]
+def getMenu(id, object, request):
+ """Return menu item entries in a TAL-friendly form."""
+ menu = zapi.getUtility(IBrowserMenu, id)
+
+ result = []
+ for name, item in zapi.getAdapters((object, request),
+ menu.getMenuItemType()):
+ if item.available():
+ result.append(item)
+
+ # Now order the result. This is not as easy as it seems.
+ #
+ # (1) Look at the interfaces and put the more specific menu entries
+ # to the front.
+ # (2) Sort unabigious entries by order and then by title.
+ ifaces = list(providedBy(removeSecurityProxy(object)).__iro__)
+ result = [(ifaces.index(item._for or Interface),
+ item.order, item.title, item) for item in result]
+ result.sort()
+
+ res = []
+ for index, order, title, item in result:
+ identifier = '%s_%s' % (item._for.__identifier__.split('.')[-1],
+ item.action.split('/')[-1])
+ identifier = identifier.replace(' ', '_').lower()
+ res.append({'title': item.title,
+ 'description': item.description,
+ 'action': item.action,
+ 'selected': (item.selected() and u'selected') or u'',
+ 'icon': item.icon,
+ 'extra': item.extra,
+ 'submenu': (IBrowserSubMenuItem.providedBy(item) and
+ getMenu(item.submenuId, object, request)) or None,
+ 'identifier': identifier,
+ })
+ return res
+
from Products.Five import security
import zope.thread
@@ -61,10 +100,8 @@
# from the object_id and the action url. That is sure
# to be unique.
action = str(entry['action'])
- if object is None:
- act_id = 'action_%s' % action
- else:
- act_id = 'action_%s_%s' % (object.getId(), action)
+ meta_type = getattr(object, 'meta_type', '')
+ act_id = entry['identifier']
if entry.get('filter') is None:
filter = None
Modified: z3/CMFonFive/trunk/version.txt
==============================================================================
--- z3/CMFonFive/trunk/version.txt (original)
+++ z3/CMFonFive/trunk/version.txt Tue Apr 11 20:25:57 2006
@@ -1 +1 @@
-CMFonFive-1.3.2
+CMFonFive-1.3.3
More information about the z3-checkins
mailing list