[Grok-dev] Dependency between classes to be grokked
Santiago Videla
santiago.videla at gmail.com
Sat Dec 13 10:38:47 EST 2008
Hi... me again :)
I guess that I was a little bit tired last night.
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.
Now there is an issue that I don't know how to tackle
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
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
Regards
On Sat, Dec 13, 2008 at 3:53 AM, Santiago Videla
<santiago.videla at gmail.com>wrote:
> Hi,
>
> I'm working on megrok.menu
> As far I understand, it hasn't the possibility to use sub-menus, and I
> would like to use those.
>
> 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)
>
> 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
>
> def execute(self, factory, config, name, title, description, \
> menuitem=None, context=None, layer=None,
> permission=None):
>
> menuDirective(config, id=name, class_=factory,
> title=title, description=description)
>
> # If menuitem directive is used, then we have to register the
> #grokked Menu as a MenuItem for another Menu
>
> if menuitem:
> menu_id, icon, filter, order = menuitem
> try:
> menu = config.resolve('zope.app.menus.'+menu_id)
> except ConfigurationError, v:
> raise GrokError("The %r menu could not be found. Please
> use "
> "megrok.menu.Menu to register a menu
> first."
> % menu_id, factory)
>
> subMenuItemDirective(config, menu=menu, for_=context,
> submenu=name,
> title=title, description=description,
> icon=icon,
> filter=filter, permission=permission,
> layer=layer,
> order=order, action='')
>
> return True
>
>
> The problem that I found is that
>
> menu = config.resolve('zope.app.menus.'+menu_id)
>
> 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?
>
> Example:
>
> class Clients(megrok.menu.Menu):
> grok.name('clients_menu')
> grok.title('Clients')
> megrok.menu.menuitem('main_menu')
>
> def render(self):
> pass
>
> class ClientsItem(grok.View):
> grok.title('Addclient')
> megrok.menu.menuitem('clients_menu')
>
> def render(self):
> return 'add client view'
>
> class MainMenu(megrok.menu.Menu):
> grok.name('main_menu')
> grok.title('Main menu')
> grok.description('App menu')
>
> this doesn't work, because Clients(megork.menu.Menu) is grokked before
> MainMenu
>
> if I change Clients to NClients (N after M) it does work, but I guess that
> it's not the solution to this problem...
>
> I already try to make 2 different grokkers with differents priorities
> (using martian.priority) but nothing changes
>
> I need some help... please :)
>
> Regards
>
> --
> Santiago Videla
> www.revolucionesweb.com.ar
> http://www.linkedin.com/in/svidela
>
> 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 at s tod at s somos.
>
--
Santiago Videla
www.revolucionesweb.com.ar
http://www.linkedin.com/in/svidela
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 at s tod at s somos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20081213/f20a6a93/attachment-0001.html
More information about the Grok-dev
mailing list