[Zope-dev] Non-ZCML config for ZCA. (Was: Anyone want to do Google Summer of code mentoring for PSF?)
Lennart Regebro
regebro at gmail.com
Mon Mar 21 07:47:56 EDT 2011
I haven't read through the whole discussion in detail, so I'm sure I
repeat some of what has been said already, but here is my point of
view.
1. Yes, Grok is pretty implicit. If it's soo implecit is a matter of
taste, but much of the implicitness makes sense. You typically do have
a model and a view and a template, and the model and view are
typically in one module, and has a name similar to the template. That
implicitness however only makes sense in the specific context of web
applications. There is no reasonably way to have that implicitness
with components and adapters. So a configuration for the ZCA in
general can't be implicit.
2. That doesn't mean we can't use grok-style configuration though.
3. Although Python 3 means we can't. We'll have to use decorators.
4. zope.interface already does, and zope.component will as well, once
it's ported. That means we get things like:
class IMyFace(Interface):
whatevah
class IMyFeet(Interface):
something
@implementer(IMyFace)
class MyFace(object):
yeahyeah
@adapter(IMyFace, IMyFeet)
class FootInMouth(object):
def __init__(self, mouth, foot):
pass
The @adapter decorator so far only handles functions, but will be
extended to classes once we port zope.component. I think also adapter
today will only mark the object as adapts(...) does, but you will
still use zcml to register the adapter. So probably we still need
@adapter (as it already exists) and also another decorator (say
@adapt() maybe?) that will both mark the class and register it in the
registry, and hence do the same as the <adapter ... /> directive does
today.
Then we have subscriber, utility, resource and view directives.
There's no particular reason I know of that means they couldn't be
class decorators as well.
That takes care of most of the configuration needed for the ZCA
itself. How to deal with the rest probably gets more obvious once
we've done this.
//Lennart
More information about the Zope-Dev
mailing list