web/action.py
branch3.5
changeset 3233 7ac07c3a9659
parent 3228 7b05b2709439
child 3230 1d25e928c299
child 3272 f46f2082468b
equal deleted inserted replaced
3223:480b003cd31b 3233:7ac07c3a9659
    35     site_wide = True # don't want user to configurate actions
    35     site_wide = True # don't want user to configurate actions
    36     category = 'moreactions'
    36     category = 'moreactions'
    37     # actions in category 'moreactions' can specify a sub-menu in which they should be filed
    37     # actions in category 'moreactions' can specify a sub-menu in which they should be filed
    38     submenu = None
    38     submenu = None
    39 
    39 
       
    40     def actual_actions(self):
       
    41         yield self
       
    42 
    40     def fill_menu(self, box, menu):
    43     def fill_menu(self, box, menu):
    41         """add action(s) to the given submenu of the given box"""
    44         """add action(s) to the given submenu of the given box"""
    42         menu.append(box.box_action(self))
    45         for action in self.actual_actions():
       
    46             menu.append(box.box_action(action))
    43 
    47 
    44     def url(self):
    48     def url(self):
    45         """return the url associated with this action"""
    49         """return the url associated with this action"""
    46         raise NotImplementedError
    50         raise NotImplementedError
    47 
    51 
    48     def html_class(self):
    52     def html_class(self):
    49         if self.req.selected(self.url()):
    53         if self.req.selected(self.url()):
    50             return 'selected'
    54             return 'selected'
    51         if self.category:
    55         if self.category:
    52             return 'box' + self.category.capitalize()
    56             return 'box' + self.category.capitalize()
       
    57 
       
    58     def build_action(self, title, path, **kwargs):
       
    59         return UnregisteredAction(self.req, self.rset, title, path, **kwargs)
    53 
    60 
    54 
    61 
    55 class UnregisteredAction(Action):
    62 class UnregisteredAction(Action):
    56     """non registered action used to build boxes. Unless you set them
    63     """non registered action used to build boxes. Unless you set them
    57     explicitly, .vreg and .schema attributes at least are None.
    64     explicitly, .vreg and .schema attributes at least are None.