[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/publisher/browser/menumeta.py refactored the menuItemsDirective so you can easily change the MenuItem implementation in subclasses

Christian Zagrodnick cz at gocept.com
Tue Mar 6 03:47:32 EST 2007


Log message for revision 73000:
  refactored the menuItemsDirective so you can easily change the MenuItem implementation in subclasses

Changed:
  U   Zope3/trunk/src/zope/app/publisher/browser/menumeta.py

-=-
Modified: Zope3/trunk/src/zope/app/publisher/browser/menumeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/menumeta.py	2007-03-06 08:42:53 UTC (rev 72999)
+++ Zope3/trunk/src/zope/app/publisher/browser/menumeta.py	2007-03-06 08:47:32 UTC (rev 73000)
@@ -144,7 +144,11 @@
 class menuItemsDirective(object):
     """Register several menu items for a particular menu."""
 
-    def __init__(self, _context, menu, for_, layer=IDefaultBrowserLayer, permission=None):
+    menuItemClass = BrowserMenuItem
+    subMenuItemClass = BrowserSubMenuItem
+
+    def __init__(self, _context, menu, for_, layer=IDefaultBrowserLayer,
+                 permission=None):
         self.for_ = for_
         self.menuItemType = menu
         self.layer = layer
@@ -164,7 +168,7 @@
             _order_counter[self.for_] = order + 1
 
         factory = MenuItemFactory(
-            BrowserMenuItem,
+            self.menuItemClass,
             title=title, description=description, icon=icon, action=action,
             filter=filter, permission=permission, extra=extra, order=order,
             _for=self.for_)
@@ -186,7 +190,7 @@
             _order_counter[self.for_] = order + 1
 
         factory = MenuItemFactory(
-            BrowserSubMenuItem,
+            self.subMenuItemClass,
             title=title, description=description, icon=icon, action=action,
             filter=filter, permission=permission, extra=extra, order=order,
             _for=self.for_, submenuId=submenu)



More information about the Zope3-Checkins mailing list