On Saturday 21 October 2006 12:03, Tim Terlegård wrote:
> There's a really useful method "add" in IAdding. As the novice zope3
> developer I am I would like that method in IFolder (as well). Is there a
> good reason why IFolder or IWriteContainer doesn't have an add method?
> It's possible to add content to an IFolder through the IWriteContainer API,
> but I'd rather use an add method that chooses an appropriate ID for the
> object.

Choosing an ID is in general a presentation-specific task and requires the 
request object. If you do not have this requirement, feel free to add the 
method to your particular API.

> IAdding has some methods that seem to be about menus. Is this because
> IAdding should be used together with browser:addMenuItem that also does
> some menu stuff?


> Is IAdding only supposed to be used when dealing with 
> /@@+/somevieworfactory? I'd like to add stuff to the folder without
> using @@+ in the url.

"@@+" traverses to IAdding object.

You can write your own add views that do not use IAdding. This is what I do 
most of the time, but is not acceptable for general-purpose folders, like the 
default on in the ZMI.

> I want to use a formlib add form and I have a view called addEvent:
>   <browser:page
>       for="zope.app.folder.interfaces.IFolder"
>       name="addEvent"
>       class=".eventforms.EventAddForm"
>       permission="zope.ManageContent"
>       />
> Submitting the form fails though. formlib (AddFormBase) assumes that the
> context/folder provides IAdding and has an add method. So I can't use
> for="IFolder". And I can only use IAdding when having /@@+/ in the url.

Absolutely, iut has been designed this way.

> I guess I can make an adapter from IFolder to IAdding, but then I have
> to implement those menu methods that neither me or the folder care
> about.

Well, you should investigate, whether you need to use the entire adding 
machinery including the menus at all. Note that you do not *have* to use 
them. Writing your own adapter basically will duplicate IAdding.

> So what's the deal with IFolder and IAdding? Why doesn't IFolder have an
> add method?

See above.

> When should IAdding be used?

You should use it whenever you want to use it and it is necessary to use, 
which is almost never. The ZMI is a very special use case.

> Can formlib only be used with folders that are adapted to IAdding?

Of course, just write your own form.

> Why does IAdding contain menu stuff?

I don't know. 

> How do I use formlib without @@+? 

Don't depend on IAdding.

Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to