Issue16 Editing

TitleCMFonFive: NameError: Interface
Prioritybug Statusunread
Superseder Nosy Listmaurits
Assigned To Topics

Created on 2006-12-09.17:25:23 by maurits, last changed 2006-12-09.17:25:23.

Messages
msg38 Author: maurits Date: 2006-12-09.17:25:23 remove
I have only discovered CMFonFive today, thanks to Martin
Aspeli.  So I may be doing things wrong.  But I see the same
issue as reported here by Dennis Schulz:
http://codespeak.net/pipermail/z3-five/2006q4/001872.html

When I add a menu item in configure.zcml and specify
'for="*"' to register this item for every interface and I
load a web page (Zope 2.9.3, Plone 2.5 svn) I get an error:

  File
"/home/maurits/instances/mvrsite/Products/CMFonFive/fiveactionstool.py",
line 91, in getMenu
    result = [(ifaces.index(item._for or Interface),
NameError: global name 'Interface' is not defined

Indeed 'Interface' is not defined in that file.

When I specify my own interface in 'for', everything works
quite nicely, thank you!  That is actually exactly what I
want.  But others might want to specify a menu item for any
interface.

Dennis mentioned that version 1.3.2 worked for him, but that
version is not downloadable anymore here.  When I switch to
revision 23593 of CMFonFive it works again.

Okay, let's try a fix.  Adding three lines does the trick
for me:

maurits@mauritsvanrees:~/svn/CMFonFive $ svn diff
Index: fiveactionstool.py
===================================================================
--- fiveactionstool.py  (revision 35538)
+++ fiveactionstool.py  (working copy)
@@ -21,6 +21,7 @@
 from Products.CMFCore.Expression import createExprContext,
Expression
 from Products.CMFCore.utils import UniqueObject, getToolByName

+from zope.interface import Interface
 from zope.interface import providedBy
 from zope.app import zapi
 from zope.app.pagetemplate import engine
@@ -94,6 +95,8 @@

     res = []
     for index, order, title, item in result:
+        if not item._for:
+            item._for = Interface
         identifier = '%s_%s' %
(item._for.__identifier__.split('.')[-1],
                                 item.action.split('/')[-1])
         identifier = identifier.replace(' ', '_').lower()

It would be nice if this can make it into the trunk.
History
Date User Action Args
2006-12-09 17:25:23mauritscreate