[Zope-CMF] [dev] add view traversal

yuppie y.2008 at wcm-solutions.de
Mon Sep 15 07:00:47 EDT 2008


Hi Martin!


Martin Aspeli wrote:
> Jens Vagelpohl wrote:
> 
>>> b) for URLs like http://www.example.org/guestbook/+/Message
>>>
>>> The '+' view already implements IPublishTraverse, so we can't change
>>> traversal using an adapter. The only solution I can see is to replace
>>> the '+' view by a customized version.
>> This looks like a good solution. I believe Zope 3 uses the same or a  
>> similar style.
> 
> I don't think we can do this. The + view implements IAdding which has 
> special semantics. Existing types are likely to rely on + being an 
> IAdding view.
> 
> Zope 3 does use IAdding for zope.app.form/zope.formlib based add views; 
> With z3c.form, IAdding support is optional, but the preference is to 
> just use views like @@add-foo.html (note: I hate the .html convention; 
> it is superfluous and looks weird, IMHO).

Maybe it's not the best solution, but we *can* implement CMF specific 
behavior for portal_type names and fall back to the default behavior for 
the rest. Either by overriding Five's ContentAdding view completely or 
by traversal hacking.

>>> 3.) For which context should we register the add views?
>>> -------------------------------------------------------
>>>
>>> The add views will depend on special portal type handling done by the
>>> traverser. So we register the add views for traverser?
> 
> No. That's how IAdding works, and it's basically what we're trying to 
> avoid. If the context of the view is the IAdding view, then self.context 
> is not a content item, which makes for all kinds of self.context.context 
> type lookups, messes with vocabulary factories, makes security tricky in 
> some cases, and generally is confusing.
> 
> (If you *do* want this, then we should just use CMFAdding form 
> Products.Five, by the way).
> 
> The add view should be registered for IContainerish, unless it's a type 
> addable only in one particular type of container.

You mean for IFolderish?

I had already forgotten all the IAdding issues because I don't use it 
anymore. But you are right.

> The add view needs to do some checking that adding is allowed, too; see 
> the pasted file above.

It always has to check container constraints. isConstructionAllowed is 
redundant if the view is guarded by the same permission as the factory. 
But we can't be sure that's the case for a default view, so thanks for 
the hint.

> One last thing to note: You need to put the portal type in the URL, but 
> portal types can have spaces and the like in the name. That's probably 
> not a problem, but there may be a case for some kind of normalisation.

CMFDefault has the 'News Item' type, I'll make sure things work with spaces.


Cheers,

	Yuppie



More information about the Zope-CMF mailing list