[Grok-dev] megrok.menu 0.2 released
Santiago Videla
santiago.videla at gmail.com
Wed Apr 15 09:17:17 EDT 2009
Hi,
this is a limitation in megrok.menu, but I'm not sure if it's a megrok.menu
limitation or a grokking limitation.
The thing is that, as far I understand, the grokking order can be set within
the same module, that's why if you put, menus and views in the same file,
things are right grokked. You may want to take a look to this thread [1]
What you could try to do is this:
instead of just a file called menus.py, create a folder, let's say:
grokapp/
src/
grokapp/
configure.zcml
app.py
menus/
- __init__.py
- menus.py
- configure.zcml
Put your menus definitions in menus.py and in `configure.zcml` put
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok">
<grok:grok package="." />
</configure>
Now, in the main configure.zcml in your grok application you should do:
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok">
<include package="grok" />
<includeDependencies package="." />
<!-- Here we force that menus module it's grokked first that nothing --/>
<include package=".menus" />
<grok:grok package="." />
</configure>
By doing this, you should be able to define your views in the app.py file
and register menuitems in the menus defined inside `menus` module.
Hope it helps
Best Regards
[1] http://mail.zope.org/pipermail/grok-dev/2008-December/006824.html
2009/4/15 Jeroen Michiel <jmichiel at yahoo.com>:
> >
> > I seem to be having problems with the order of 'grokking':
> > I put all my menu definitions in 'menus.py' and then add views to these
> > menus by name.
> > For instance I have a
> >
> > class VersionTasksMenu(megrok.menu.Menu):
> > grok.name('version-tasks')
> > grok.title('Tasks')
> > grok.description('All you can do on a version')
> >
> > Then in another file where views for a specific model are defined I have
> > class AddCandidateView(grok.View):
> > grok.context(IVersion)
> > grok.template('default')
> > grok.name('addcandidate')
> > grok.title('Add a Candidate')
> > grok.description('Add a new Candidate to the list of candidates for
> this
> > video')
> > megrok.menu.menuitem('version-tasks')
> >
> > And Grok keeps complaining with:
> > GrokError: The u'version-tasks' menu could not be found. Please use
> > megrok.menu.Menu to register a menu first.
> >
> > The only way to solve it is to add the menu definition in the same file
> as
> > the view and above it.
> > This is not the way I want my code structured, however (there may be
> other
> > views that will be registered to this menu in other files later on)! How
> can
> > I fix this? can I somehow 'force' the grokking order, or does this need
> to
> > be solved in megrok.menu?
> >
> > Another question: I saw there also is a z3c.menu.ready2go package, which
> > seems more powerful. Would this be a big deal getting it to work in Grok
> (I
> > figure i'd have to be writing some zcml, judging from the PyPI docs)?
> > --
> > View this message in context:
> http://www.nabble.com/megrok.menu-0.2-released-tp22291198p23054977.html
> > Sent from the Grok mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > Grok-dev mailing list
> > Grok-dev at zope.org
> > http://mail.zope.org/mailman/listinfo/grok-dev
> >
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
>
--
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/20090415/1e01cc8e/attachment.html
More information about the Grok-dev
mailing list