[Zope3-checkins] CVS: Zope3/src/zope/app/browser/container - adding.py:1.23

Jim Fulton cvs-admin at zope.org
Wed Dec 3 00:41:20 EST 2003


Update of /cvs-repository/Zope3/src/zope/app/browser/container
In directory cvs.zope.org:/tmp/cvs-serv18939/src/zope/app/browser/container

Modified Files:
	adding.py 
Log Message:
Updated to search the standard add menu, zope.app.container.add, as
well as the add menu defined for an adding object.


=== Zope3/src/zope/app/browser/container/adding.py 1.22 => 1.23 ===
--- Zope3/src/zope/app/browser/container/adding.py:1.22	Mon Oct  6 18:08:51 2003
+++ Zope3/src/zope/app/browser/container/adding.py	Wed Dec  3 00:40:49 2003
@@ -42,6 +42,8 @@
 
 from zope.proxy import removeAllProxies
 
+from zope.app.container.constraints import checkFactory
+
 class BasicAdding(BrowserView):
 
     implements(IAdding, IPublishTraverse)
@@ -151,18 +153,34 @@
 
 class Adding(BasicAdding):
 
-    menu_id = "add_content"
+    menu_id = None
 
     index = ViewPageTemplateFile("add.pt")
 
-    def addingInfo(wrapped_self):
+    def addingInfo(self):
         """Return menu data.
 
         This is sorted by title.
         """
-        menu_service = zapi.getService(wrapped_self.context, "BrowserMenu")
-        result = menu_service.getMenu(wrapped_self.menu_id,
-                                      wrapped_self,
-                                      wrapped_self.request)
+        container = self.context
+        menu_service = zapi.getService(container, "BrowserMenu")
+        result = []
+        for menu_id in (self.menu_id, 'zope.app.container.add'):
+            if not menu_id:
+                continue
+            for item in menu_service.getMenu(menu_id, self, self.request):
+                extra = item.get('extra')
+                if extra:
+                    factory = extra.get('factory')
+                    if factory:
+                        factory = zapi.getFactory(container, factory)
+                        if not checkFactory(container, None, factory):
+                            continue
+                result.append(item)
+                
         result.sort(lambda a, b: cmp(a['title'], b['title']))
         return result
+
+class ContentAdding(Adding):
+
+    menu_id = "add_content"




More information about the Zope3-Checkins mailing list