web/action.py
changeset 3230 1d25e928c299
parent 2890 fdcb8a2bb6eb
parent 3228 7b05b2709439
child 3293 69c0ba095536
--- a/web/action.py	Mon Sep 14 11:25:56 2009 +0200
+++ b/web/action.py	Tue Sep 15 15:01:41 2009 +0200
@@ -31,8 +31,18 @@
                                      'useractions', 'siteactions', 'hidden'),
                          help=_('context where this component should be displayed')),
     }
-    site_wide = True # don't want user to configuration actions eproperties
+    site_wide = True # don't want user to configurate actions
     category = 'moreactions'
+    # actions in category 'moreactions' can specify a sub-menu in which they should be filed
+    submenu = None
+
+    def actual_actions(self):
+        yield self
+
+    def fill_menu(self, box, menu):
+        """add action(s) to the given submenu of the given box"""
+        for action in self.actual_actions():
+            menu.append(box.box_action(action))
 
     def url(self):
         """return the url associated with this action"""
@@ -44,6 +54,9 @@
         if self.category:
             return 'box' + self.category.capitalize()
 
+    def build_action(self, title, path, **kwargs):
+        return UnregisteredAction(self.req, self.rset, title, path, **kwargs)
+
 
 class UnregisteredAction(Action):
     """non registered action used to build boxes. Unless you set them
@@ -72,7 +85,8 @@
     __select__ = (match_search_state('normal') & one_line_rset()
                   & partial_relation_possible(action='add')
                   & partial_may_add_relation())
-    category = 'addrelated'
+
+    submenu = 'addrelated'
 
     def url(self):
         current_entity = self.rset.get_entity(self.row or 0, self.col or 0)