[Zope3-dev] Re: Zope3 magic makes me cranky.
Jim Fulton
jim@zope.com
Mon, 14 Jul 2003 16:49:53 -0400
Fred L. Drake, Jr. wrote:
> Shane Hathaway writes:
> > In any case, magically generating classes is crossing a line, don't you
> > think? It's especially bad if the class pretends to have been loaded
> > from a Python module. There must be a better way.
>
> I'd certainly prefer to see a normal factory involved, though I think
> what's happening in the <page> directive is this: The class attribute
> of the directive can specify a class which may not inherit from one of
> the page view classes (or implement the right interface), in which
> case it is mixed-in with a common classes that implements all the
> basic stuff. This is inherantly asking for a disaster, I think.
>
> But I think this was something that Jim wanted to support easier
> entrance to using Zope 3. If we can convince him that this is
> misguided, that would be a good thing, and would allow a lot of
> simplification in this case. And we wouldn't need such magically
> incanted classes.
It's not fun being channeled.
Here are the *real* reasons for generating a class:
- We want to be able to give a page a permission.
This means that we need to associate a security
checker with the view that ultimately gets created.
The simplest way to do this is to generate a class,
but it's not the only way to do it.
- We want to be able to specify a template in ZCML.
The template needs to function as a method of the view.
It is a descriptor. Python doesn't support instance
descriptors. We need to install it in a class, but, of
course, we can't install it in the original class.
There is probably some other way to do this.
The fact that less ceremony is needed in view classes is,
IMO, a valuable bonus.
Jim
--
Jim Fulton mailto:jim@zope.com Python Powered!
CTO (703) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org