[z3-checkins] r8240 - in z3/CMFonFive/branch/regebro-action_menus: . tests/CMFonFiveTest tests/CMFonFiveTest/www

regebro at codespeak.net regebro at codespeak.net
Wed Jan 12 18:16:04 MET 2005


Author: regebro
Date: Wed Jan 12 18:16:03 2005
New Revision: 8240

Added:
   z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/
   z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/__init__.py   (contents, props changed)
   z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/cmfcontent.py   (contents, props changed)
   z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/configure.zcml   (contents, props changed)
   z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/interfaces.py   (contents, props changed)
   z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/www/
   z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/www/cmfContentAdd.zpt   (contents, props changed)
Modified:
   z3/CMFonFive/branch/regebro-action_menus/__init__.py
   z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py
   z3/CMFonFive/branch/regebro-action_menus/interfaces.py
Log:
First complete version. Now *all* menuItems will be actions, and the action category will be set to the menu name. 
Also, a CMFonFiveTest product is added, in the same patters as Five/FiveTest. It's not currently used by the tests, but used by me for testing. It may go away...


Modified: z3/CMFonFive/branch/regebro-action_menus/__init__.py
==============================================================================
--- z3/CMFonFive/branch/regebro-action_menus/__init__.py	(original)
+++ z3/CMFonFive/branch/regebro-action_menus/__init__.py	Wed Jan 12 18:16:03 2005
@@ -3,7 +3,7 @@
 $Id$
 """
 from Products.CMFCore.utils import ToolInit
-import fiveactionstool
+import fiveactionstool, interfaces
 
 def initialize(context):
 

Modified: z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py
==============================================================================
--- z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py	(original)
+++ z3/CMFonFive/branch/regebro-action_menus/fiveactionstool.py	Wed Jan 12 18:16:03 2005
@@ -16,7 +16,7 @@
 from Products.Five.globalbrowsermenuservice import \
      globalBrowserMenuService
 
-    
+
 class FiveActionsTool( UniqueObject, SimpleItem, ActionProviderBase ):
     """ Links content to discussions.
     """
@@ -30,21 +30,23 @@
 
     def getReqestURL(self):
         return self.REQUEST.URL
-    
+
     security.declarePrivate('listActions')
     def listActions(self, info=None, object=None):
         """ List all the actions defined by a provider.
         """
+        # Necessary to make the Request look like a Zope3 request
         self.REQUEST.getURL = self.getReqestURL
-        menu = globalBrowserMenuService.getMenu(u'actionmenu', object, self.REQUEST)
         actions = []
-        for entry in menu:
-            act = {}
-            act['category'] = 'folder'
-            act['url'] = str(entry['action'])
-            act['name'] = 'action_%s%s' % (object.getId(), act['url'])
-            act['title'] = str(entry['title'])
-            actions.append(act)
+        for mid in globalBrowserMenuService._registry.keys():
+            menu = globalBrowserMenuService.getMenu(mid, object, self.REQUEST)
+            for entry in menu:
+                act = {}
+                act['category'] = str(mid)
+                act['url'] = str(entry['action'])
+                act['name'] = 'action_%s%s' % (object.getId(), act['url'])
+                act['title'] = str(entry['title'])
+                actions.append(act)
         return actions or ()
 
 

Modified: z3/CMFonFive/branch/regebro-action_menus/interfaces.py
==============================================================================
--- z3/CMFonFive/branch/regebro-action_menus/interfaces.py	(original)
+++ z3/CMFonFive/branch/regebro-action_menus/interfaces.py	Wed Jan 12 18:16:03 2005
@@ -75,12 +75,13 @@
         edit began.
         """
 
-from zope.app.publisher.browser.interfaces.browser import IBrowserMenu
+from zope.app.publisher.interfaces.browser import IBrowserMenu
+from zope.schema import TextLine
 
 class IActionMenu(IBrowserMenu):
 
     category = TextLine(
-        title=_("Category"),
-        description=_("The action category of this action menu"),
+        title=u"Category",
+        description=u"The action category of this action menu",
         required=True)
 

Added: z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/__init__.py
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/__init__.py	Wed Jan 12 18:16:03 2005
@@ -0,0 +1,11 @@
+import cmfcontent
+
+def initialize(context):
+
+    context.registerClass(
+        cmfcontent.CMFContent,
+        constructors = (cmfcontent.manage_addCMFContentForm,
+                        cmfcontent.manage_addCMFContent),
+        )
+
+

Added: z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/cmfcontent.py
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/cmfcontent.py	Wed Jan 12 18:16:03 2005
@@ -0,0 +1,43 @@
+from OFS.SimpleItem import SimpleItem
+from Globals import InitializeClass
+from AccessControl import ClassSecurityInfo
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from zope.interface import implements
+from interfaces import ICMFContent
+
+class CMFContent(SimpleItem):
+    implements(ICMFContent)
+
+    meta_type = 'CMFonFive Content'
+    security = ClassSecurityInfo()
+
+    def __init__(self, id, title):
+        self.id = id
+        self.title = title
+
+    security.declarePublic('mymethod')
+    def mymethod(self):
+        return "Hello world"
+
+InitializeClass(CMFContent)
+
+
+manage_addCMFContentForm = PageTemplateFile(
+    "www/cmfContentAdd", globals(),
+    __name__ = 'manage_addCmfContentForm')
+
+def manage_addCMFContent(self, id, title, REQUEST=None):
+    """Add the simple content."""
+    id = self._setObject(id, CMFContent(id, title))
+
+    if REQUEST is None:
+        return
+    try:
+        u = self.DestinationURL()
+    except:
+        u = REQUEST['URL1']
+    if REQUEST.has_key('submit_edit'):
+        u = "%s/%s" % (u, urllib.quote(id))
+    REQUEST.RESPONSE.redirect(u+'/manage_main')
+
+    return ''

Added: z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/configure.zcml
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/configure.zcml	Wed Jan 12 18:16:03 2005
@@ -0,0 +1,21 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+           xmlns:browser="http://namespaces.zope.org/browser"
+           xmlns:five="http://namespaces.zope.org/five">
+
+  <five:traversable class=".cmfcontent.CMFContent" />
+
+  <!-- browser menu support -->
+  <browser:menu
+      id="folder"
+      title="CMF menu" />
+
+  <browser:menuItem
+      for=".interfaces.ICMFContent"
+      menu="folder"
+      title="Test Menu Item"
+      action="seagull.html"
+      description="This is a test menu item"
+      permission="zope2.Public"
+      />
+
+</configure>

Added: z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/interfaces.py
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/interfaces.py	Wed Jan 12 18:16:03 2005
@@ -0,0 +1,5 @@
+from zope.interface import Interface
+
+class ICMFContent(Interface):
+    pass
+

Added: z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/www/cmfContentAdd.zpt
==============================================================================
--- (empty file)
+++ z3/CMFonFive/branch/regebro-action_menus/tests/CMFonFiveTest/www/cmfContentAdd.zpt	Wed Jan 12 18:16:03 2005
@@ -0,0 +1,45 @@
+<h1 tal:replace="structure here/manage_page_header">Header</h1>
+
+<h2 tal:define="form_title string:Add CMF Content"
+    tal:replace="structure here/manage_form_title">Form Title</h2>
+
+<p class="form-help">
+Add CMF Content
+</p>
+
+<form action="manage_addCMFContent" method="post">
+<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">
+    Title
+    </div>
+    </td>
+    <td align="left" valign="top">
+    <input type="text" name="title" size="40" />
+    </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_add"
+     value=" Add " />
+    </div>
+    </td>
+  </tr>
+</table>
+</form>
+
+<h1 tal:replace="structure here/manage_page_footer">Footer</h1>


More information about the z3-checkins mailing list