[Zope-CMF] CMF add views and <browser:page />
Martin Aspeli
optilude at gmx.net
Thu Dec 11 17:26:10 EST 2008
Hi Yuppie,
>>>>> Mmmm... I'm not sure most people would find it natural to think about
>>>>> the add form as an adapter like this.
>>>> Well. I find it natural to think about browser pages as a special kind
>>>> of adapters.
>>> Having explained this to a lot of different people with different levels
>>> of experience, I think "natural" is too strong a word for most people.
>>> The fact that browser views are adapters is an implementation detail
>>> that often give people an "aha!" type reaction when they really
>>> understand it. However, a lot of people will use browser views for a
>>> long time without really understanding adapters (if they ever do or care).
>
> Well. I guess it depends on your perspective. For Plone users adapters
> might be implementation details, for others they are important tools for
> solving many different problems.
Adapters are of course important tools. However, the fact that browser
pages are named multi-adapters that provide Interface and adapt the
context object and the request, normally via a marker interface called a
layer that's applied to the request during traversal, is an
implementation detail, and one that requires quite a lot of explanation
and even then doesn't make a whole lot of sense unless you are quite
familiar with Zope 3's brand of the adapter pattern. It took me 32 words
to state that as completely and concisely as I could, without even
explaining any of the concepts.
The concept of a named multi-adapter is an order of magnitude more
advanced than, say, page templates skin layers or the concept of having
a class/template that's registered in an XML file. People who are not
steeped in software design patterns can learn the latter quite quickly.
They struggle with the former, Plone user or not.
> Providing customized solutions for specific use cases makes it easier to
> solve these use cases, but it also makes the framework more complex and
> less framework-ish.
Then why do we have <browser:page />?
You could of course do:
<adapter
for=".interfaces.IMyType
Products.CMFDefault.interfaces.ICMFDefaultLayer"
provides="zope.interface.Interface"
name="myview"
factory=".myview.MyView"
/>
<class class=".myview.MyView">
<require
permission="zope2.View"
allowed_interface="zope.publisher.interfaces.browser.IBrowserPage"
/>
</class>
> I can't see a need for the directive you propose.
> But if you also volunteer to maintain the additional code in the long
> run, I can live with it.
I can probably do that, but I'd like to know if others agree. I actually
don't have an immediate need for it myself, since I've implemented the
same thing for my specific use case using a martian grokker, but I
suspect people would prefer an analogue to <browser:page /> rather than
having to register their add views manually.
If we want people to use add forms (in Plone we certainly do - premature
object creation sucks), then we need to make it easy to do so.
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Zope-CMF
mailing list