Grok openspace at Plone Conference
Grok is a way to simplify the entry of people to Zope 3 (now called Zope Toolkit). Although Grok directly uses Zope Toolkit and it wasn't possible to use it directly in Zope 2, Grok people made a refactoring job to extract the core components of Grok to a smaller packages called grokcore.*
In that way Godefroi and other people like Lennart Regebro, were able to write five.grok: the Zope2 integration layer for Grok.
Now we can easily write views (browser views for example, because there are many other supported things) easily without needing to know all that ZCML stuff needed to register a browser view:
from five import grok # assuming content is in a module called content from content import MyContent class MyView(grok.View): grok.context(MyContent) def render(self): return u'Me grok view Plone!'
Is not that easy? We just need one line, yes one line, of ZCML to load that:
<grok:grok package="."/>
Wow ! That avoids many lines of ZCML in our configure.zcml.
Grok is a way to avoid a lot of boilerplate code and ZCML lines without losing control on all those registration. It's another way of doing the same as we do writing ZCML, but without writing it.
Although there are many things already done and usable in Plone, they want to identify what isn't and write grokkers (classes that do the same as ZCML registrations) for them. Here are some of those things, identified in the open space:
- Portlets: there is something done in a package called plone.grok, but it's old and needs upgrading.
- GenericSetup: avoid all that code to register a GS profile or import steps.
- ContentRules.
There is also a package to grok z3c.forms in Plone.
I think this will be very useful for as at CS.
You may be interested in these other articles
JakiZU! promoting food sustainability
Oct 28, 2024