Hi... me again :)<br><br>I guess that I was a little bit tired last night.<br><br>I created a separated grokker for sub-menus items with a lower priority than the MenuGrokker and it&#39;s working.&nbsp; I also added some automated tests for this new functionality and it&#39;s all in the branch right now.<br>
<br>Now there is an issue that I don&#39;t know how to tackle<br><br>SubMenuItems wait until all Menu have been grokked, but if someone want to create more that 1 level sub-menus, there is a problem. Because Level1 and Level2 are SubMenuItems, both are grokked with the same priority, but Level2 will depends on Level1<br>
<br>If you guys have any idea, please let me know. Also, if someone could take a look to the branch, it would be great to know if I&#39;m on the right path<br><br>Regards<br><br><div class="gmail_quote">On Sat, Dec 13, 2008 at 3:53 AM, Santiago Videla <span dir="ltr">&lt;<a href="mailto:santiago.videla@gmail.com">santiago.videla@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>I&#39;m working on megrok.menu<br>As far I understand, it hasn&#39;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 &quot;understood&quot; 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>&nbsp;&nbsp;&nbsp; def execute(self, factory, config, name, title, description, \<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; menuitem=None, context=None, layer=None, permission=None):<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; menuDirective(config, id=name, class_=factory,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title=title, description=description)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # If menuitem directive is used, then we have to register the <br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #grokked Menu as a MenuItem for another Menu<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if menuitem:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; menu_id, icon, filter, order = menuitem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; menu = config.resolve(&#39;zope.app.menus.&#39;+menu_id)<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; except ConfigurationError, v:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise GrokError(&quot;The %r menu could not be found.&nbsp; Please use &quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;megrok.menu.Menu to register a menu first.&quot;<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; % menu_id, factory)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subMenuItemDirective(config, menu=menu, for_=context, submenu=name,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title=title, description=description, icon=icon,<br>


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter=filter, permission=permission, layer=layer,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; order=order, action=&#39;&#39;)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return True<br><br><br>The problem that I found is that <br>


<br>menu = config.resolve(&#39;zope.app.menus.&#39;+menu_id)<br><br>It&#39;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>&nbsp;&nbsp;&nbsp; <a href="http://grok.name" target="_blank">grok.name</a>(&#39;clients_menu&#39;)<br>&nbsp;&nbsp;&nbsp; grok.title(&#39;Clients&#39;)<br>&nbsp;&nbsp;&nbsp; megrok.menu.menuitem(&#39;main_menu&#39;)<br>

<br>&nbsp;&nbsp;&nbsp; def render(self):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pass<br><br>class ClientsItem(grok.View):<br>
&nbsp;&nbsp;&nbsp; grok.title(&#39;Addclient&#39;)<br>
&nbsp;&nbsp;&nbsp; megrok.menu.menuitem(&#39;clients_menu&#39;)<br>
<br>
&nbsp;&nbsp;&nbsp; def render(self):<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &#39;add client view&#39;<br><br>class MainMenu(megrok.menu.Menu):<br>&nbsp;&nbsp;&nbsp; <a href="http://grok.name" target="_blank">grok.name</a>(&#39;main_menu&#39;)<br>&nbsp;&nbsp;&nbsp; grok.title(&#39;Main menu&#39;)<br>&nbsp;&nbsp;&nbsp; grok.description(&#39;App menu&#39;)<br>


<br>this doesn&#39;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&#39;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><font color="#888888"><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>
</font></blockquote></div><br><br clear="all"><br>-- <br>Santiago Videla<br><a href="http://www.revolucionesweb.com.ar">www.revolucionesweb.com.ar</a><br><a href="http://www.linkedin.com/in/svidela">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>