def _handle_menu(self): if self.menu: menuItemDirective(self._context, self.menu, self.for_ or self.schema, '@@' + self.name, self.title, permission=self.permission, layer=self.layer)
def _handle_menu(self): if self.menu or self.title: if (not self.menu) or (not self.title): raise ValueError("If either menu or title are specified, " "they must both be specified") # Add forms are really for IAdding components, so do not use # for=self.schema. menuItemDirective( self._context, self.menu, self.for_, '@@' + self.name, self.title, permission=self.permission, layer=self.layer, description=self.description)
def containerViews(_context, for_, contents=None, add=None, index=None, layer=IDefaultBrowserLayer): """Set up container views for a given content type.""" if for_ is None: raise ValueError("A for interface must be specified.") if contents is not None: from zope.app.menus import zmi_views page(_context, name='contents.html', permission=contents, for_=for_, layer=layer, class_=Contents, attribute='contents', menu=zmi_views, title=_('Contents')) if index is not None: page(_context, name='index.html', permission=index, for_=for_, layer=layer, class_=Contents, attribute='index') if add is not None: from zope.app.menus import zmi_actions viewObj = view(_context, name='+', layer=layer, for_=for_, permission=add, class_=Adding) menuItemDirective( _context, zmi_actions, for_, '+', _('Add'), permission=add, layer=layer, filter= 'python:modules["zope.app.container.browser.metaconfigure"].menuFilter(context, request)' ) viewObj.page(_context, name='index.html', attribute='index') viewObj.page(_context, name='action.html', attribute='action') viewObj()
def _handle_menu(_context, menu, title, for_, name, permission, layer=IDefaultBrowserLayer): if menu or title: if not (menu and title): raise ConfigurationError( "If either menu or title are specified, they must " "both be specified.") if len(for_) != 1: raise ConfigurationError( "Menus can be specified only for single-view, not for " "multi-views.") if menuItemDirective is None: import warnings warnings.warn_explicit( 'Page directive used with "menu" argument, while "zope.browsermenu" ' 'package is not installed. Doing nothing.', UserWarning, _context.info.file, _context.info.line) return [] return menuItemDirective( _context, menu, for_[0], '@@' + name, title, permission=permission, layer=layer) return []
def _handle_menu(_context, menu, title, for_, name, permission, layer=IDefaultBrowserLayer): if menu or title: if not (menu and title): raise ConfigurationError( "If either menu or title are specified, they must " "both be specified.") if len(for_) != 1: raise ConfigurationError( "Menus can be specified only for single-view, not for " "multi-views.") if menuItemDirective is None: import warnings warnings.warn_explicit( 'Page directive used with "menu" argument, while "zope.browsermenu" ' 'package is not installed. Doing nothing.', UserWarning, _context.info.file, _context.info.line) return [] return menuItemDirective(_context, menu, for_[0], '@@' + name, title, permission=permission, layer=layer) return []
def _handle_menu(_context, menu, title, for_, name, permission, layer=IDefaultBrowserLayer): if not menu and not title: # Neither of them return [] if not menu or not title: # Only one or the other raise ConfigurationError( "If either menu or title are specified, they must " "both be specified.") if len(for_) != 1: raise ConfigurationError( "Menus can be specified only for single-view, not for " "multi-views.") return menuItemDirective(_context, menu, for_[0], '@@' + name, title, permission=permission, layer=layer)
def containerViews(_context, for_, contents=None, add=None, index=None, layer=IDefaultBrowserLayer): """Set up container views for a given content type.""" if for_ is None: raise ValueError("A for interface must be specified.") if contents is not None: from zope.app.menus import zmi_views page( _context, name="contents.html", permission=contents, for_=for_, layer=layer, class_=Contents, attribute="contents", menu=zmi_views, title=_("Contents"), ) if index is not None: page(_context, name="index.html", permission=index, for_=for_, layer=layer, class_=Contents, attribute="index") if add is not None: from zope.app.menus import zmi_actions viewObj = view(_context, name="+", layer=layer, for_=for_, permission=add, class_=Adding) menuItemDirective( _context, zmi_actions, for_, "+", _("Add"), permission=add, layer=layer, filter='python:modules["zope.app.container.browser.metaconfigure"].menuFilter(context, request)', ) viewObj.page(_context, name="index.html", attribute="index") viewObj.page(_context, name="action.html", attribute="action") viewObj()
def execute(self, factory, config, permission, order, context=None, layer=None, name=u'', menuitem=None, description=u'', title=u''): if menuitem is None: return False menu_id, icon, filter, enforced_order, extra = menuitem if enforced_order is None: enforced_order = order[0] or 0 try: menu = config.resolve('zope.app.menus.' + menu_id) except ConfigurationError: raise GrokError("The %r menu could not be found. Please use " "megrok.menu.Menu to register a menu first." % menu_id, factory) menuItemDirective(config, menu=menu, for_=context, action=name, title=title, description=description, icon=icon, filter=filter, permission=permission, layer=layer, order=enforced_order, extra=extra) return True
def _handle_menu(_context, menu, title, for_, name, permission, layer=IDefaultBrowserLayer): if not menu and not title: # Neither of them return [] if not menu or not title: # Only one or the other raise ConfigurationError( "If either menu or title are specified, they must " "both be specified.") if len(for_) != 1: raise ConfigurationError( "Menus can be specified only for single-view, not for " "multi-views.") return menuItemDirective( _context, menu, for_[0], '@@' + name, title, permission=permission, layer=layer)
def _handle_menu(self): if self.menu: menuItemDirective( self._context, self.menu, self.for_ or self.schema, '@@' + self.name, self.title, permission=self.permission, layer=self.layer)