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's working. I also added some automated tests for this new functionality and it's all in the branch right now.<br>
<br>Now there is an issue that I don'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'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"><<a href="mailto:santiago.videla@gmail.com">santiago.videla@gmail.com</a>></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'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><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>