Hi,<br><br>I'm working on megrok.menu<br>As far I understand, it hasn't the possibility to use sub-menus, and I would like to use those.<br><br>I was trying to understand how Menu, MenuItems and SubMenuItems are registered and what I "understood" is that sub-menus must be registered first, as a MenuBrowser (using menuDirective) and then as a SubMenuItemBrowser (using subMenuItemDirective)<br>
<br>So what I did was to add the megrok.menu.menuitem directive to the MenuGrokker (until now, was only available for MenuItemGrokker) and the execute method for the MenuGrokker is the following<br><br> def execute(self, factory, config, name, title, description, \<br>
menuitem=None, context=None, layer=None, permission=None):<br><br> menuDirective(config, id=name, class_=factory,<br> title=title, description=description)<br><br> # If menuitem directive is used, then we have to register the <br>
#grokked Menu as a MenuItem for another Menu<br> <br> if menuitem:<br> menu_id, icon, filter, order = menuitem<br> try:<br> menu = config.resolve('zope.app.menus.'+menu_id)<br>
except ConfigurationError, v:<br> raise GrokError("The %r menu could not be found. Please use "<br> "megrok.menu.Menu to register a menu first."<br>
% menu_id, factory)<br><br> subMenuItemDirective(config, menu=menu, for_=context, submenu=name,<br> title=title, description=description, icon=icon,<br>
filter=filter, permission=permission, layer=layer,<br> order=order, action='')<br><br> return True<br><br><br>The problem that I found is that <br>
<br>menu = config.resolve('zope.app.menus.'+menu_id)<br><br>It's not always resolved. It depends on the class names. The relation that I found was that Menu classes are grokked in alphabetic order, am I right? <br>
<br>Example:<br><br>class Clients(megrok.menu.Menu):<br> <a href="http://grok.name" target="_blank">grok.name</a>('clients_menu')<br> grok.title('Clients')<br> megrok.menu.menuitem('main_menu')<br>
<br> def render(self):<br>
pass<br><br>class ClientsItem(grok.View):<br>
grok.title('Addclient')<br>
megrok.menu.menuitem('clients_menu')<br>
<br>
def render(self):<br>
return 'add client view'<br><br>class MainMenu(megrok.menu.Menu):<br> <a href="http://grok.name" target="_blank">grok.name</a>('main_menu')<br> grok.title('Main menu')<br> grok.description('App menu')<br>
<br>this doesn't work, because Clients(megork.menu.Menu) is grokked before MainMenu<br><br>if I change Clients to NClients (N after M) it does work, but I guess that it's not the solution to this problem...<br><br>
I already try to make 2 different grokkers with differents priorities (using martian.priority) but nothing changes<br><br>I need some help... please :)<br><br>Regards<br><br>-- <br>Santiago Videla<br><a href="http://www.revolucionesweb.com.ar" target="_blank">www.revolucionesweb.com.ar</a><br>
<a href="http://www.linkedin.com/in/svidela" target="_blank">http://www.linkedin.com/in/svidela</a><br>
<br>Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el pensamiento que se hace corazón resplandece con la palabra sencilla y humilde que l@s tod@s somos.<br>