[Grok-dev] Grok in Zope 2: Paris Sprint first day wrap up: Success! (Kinda)

Lennart Regebro regebro at gmail.com
Fri Apr 25 12:58:00 EDT 2008


Today Godefroid and me have been working on getting grokkers into
Zope2/Plone. We are using grokcore.component and the first step was
creating a package and some tests to see if we could use
grokcore.component in Zope 2 to register adapters and utilities.

So we created five.grokkers, and did some basic tests with immediate
success! grokcore.component Rocks! And it works just fine under Zope
2.
You can see the tests here:
http://svn.zope.org/five.grokkers/trunk/five/grokkers/tests/

Next we started looking into making a grokker for Views. Those needs
security, so we are thinking we might start a grokcore.security
module, with the security grokkers et al in it. Does that seem like a
good idea?

Secondly, and the first big problem:  For Zope 2 the views are
ExtensionClasses (so they can have acquisition). Martian currently
doesn't know about ExtensionClasses, and think that they are
instances, not classes. That means martian uses the
MultiInstanceGrokker instead of MultiClassGrokker when it looks at the
class, and hence does not find the ViewGrokker we defined.

The fix for this is easy, but we want approval for it, before we do
this change. And the change is that in martian.core, we add:

try:
    from ExtensionClass import ExtensionClass
except ImportError:
    ExtensionClass = types.ClassType

and then change a line in MultiGrokker.grokkers from
        if obj_type in (type, types.ClassType):
to
        if obj_type in (type, types.ClassType, ExtensionClass):

Stylistic variations of this is possible. :)
What are the opinions on this?

-- 
Lennart Regebro: Zope and Plone consulting.
http://www.colliberty.com/
+33 661 58 14 64


More information about the Grok-dev mailing list