[Grok-dev] Rendering a menu built in another module
Simon Elbaz
simon.elbaz at free.fr
Fri Jan 9 07:41:17 EST 2009
Hi,
here is an extract of menus.py:
-----
class Adamamenu(megrok.menu.Menu):
grok.name('adamamenu')
grok.title('Adamamenu')
grok.description('')
class File(megrok.menu.SubMenuItem):
grok.name('file')
grok.title('File')
grok.description('')
megrok.menu.menuitem('adamamenu', icon=None, filter=None, order=1)
class RenderMenu(grok.View):
grok.context(Menutest)
def render(self):
menu = getUtility(IBrowserMenu, 'adamamenu')
return pformat(menu.getMenuItems(self.context, self.request))
def render_menu(self):
menu = getUtility(IBrowserMenu, 'adamamenu')
return menu.getMenuItems(self.context, self.request)
-----
An extract of infos.py that tries to display the object Adamamenu:
import menus
....
class Logo(grok.Viewlet):
grok.context(Infos)
grok.viewletmanager(Header)
grok.order(1)
def display_menu(self):
a_menu = getMultiAdapter((self.context, self.request),
name='displaymenu')
return a_menu.get_menu()
class DisplayMenu(RenderMenu):
grok.context(Infos)
def get_menu(self):
return self.render_menu()
-----
Calling viewlet.display_menu in logo.pt displays an empty menu.
Regards,
Simon
--------------------------------------------------
Santiago Videla wrote:
> Hi,
>
> I'm not sure to understand what are doing exactly.
>
> Could you paste your code??
>
> Best Regards
>
> On Thu, Jan 8, 2009 at 10:43 AM, Simon Elbaz <simon.elbaz at free.fr
> <mailto:simon.elbaz at free.fr>> wrote:
>
> Hi,
> I have 2 files:
> menus.py
> infos.py
>
> In menus.py, a menu is built using megrok.menu (with fixes on 0.14). A
> view called RenderMenu has 2 methods:
> render which display the menu correctly.
> render_menu which returns the menu structure
>
> In the file infos.py, a class called DisplayMenu subclasses RenderMenu
> and returns the menu which is now empty (whatever is put in menus.py).
>
> What should I do to get the menu - filled in menus.py - from
> DisplayMenu
> in infos.py ?
>
> Thanks for your help
> Simon
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org <mailto:Grok-dev at zope.org>
> http://mail.zope.org/mailman/listinfo/grok-dev
>
>
>
>
> --
> Santiago Videla
> www.revolucionesweb.com.ar <http://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.
More information about the Grok-dev
mailing list