[Zope3-dev] IAdding

Jim Fulton jim at zope.com
Fri Nov 12 11:47:03 EST 2004


Shane Hathaway wrote:
> On Fri, November 12, 2004 6:59 am, Jim Fulton said:
> 
>>That's not quite right.  For better or worse, IAdding views are generally
>>registered on a case-by-case basis.  This is normally done using the
>>containerViews ZCML directive that is, essentially, a macro that
>>configures
>>contents, adding, and/or index views.
> 
> 
> Ok.  I have a containerViews directive with no "add" or "index" attribute:
> 
>   <browser:containerViews
>       for="scanstone.interfaces.IProcessControl"
>       contents="zope.View"
>       />
> 
> I guess this means it creates a contents view but not an adding view.

Yup

> 
>>>- Should those undocumented methods be declared in the IAdding
>>>interface?
>>>I'm happy to add them if that's the right thing to do.
>>
>>Absolutely. This was a sorry oversight. Thanks.
> 
> 
> I was about to do it, but then I realized there's still a design issue. 
> There is a BasicAdding class that implements IAdding, and an Adding class
> that derives from BasicAdding.  If I add the methods that contents.pt
> requires to IAdding, BasicAdding will no longer fulfill the contract
> declared by IAdding.  Some code in contents.py uses BasicAdding directly. 
> My guess is that BasicAdding and Adding should be combined into a single
> class.  What do you think?

Ideally, yes, but there's a potential backward-compatability issue, as
there could be other subclasses of Adding or BasicAdding in third-party
code, as there used to be many subclasses of BasicAdded (I think).
I'd have to study this to be sure, which I don't have time to do right
now.  I you want to pursue this, I suggest you check how these are used,
which I'm sure you'll do anyway, and combine them it it seem appropriate.
We can revisit this is anything bad happens. :)

> 
>>Then why do need an adding.  If contents *requires* an adding, then that's
>>a bug in contents that we ought to fix.
> 
> 
> Ok, that makes sense.  What is the best way for a page template to detect
> whether an adding exists?  "context/@@+|nothing" comes to mind, but maybe
> there's a better way that doesn't swallow exceptions like "|nothing".

I'm not sure it would swally the right exception anyway.  I suggest adding
a haveAdding method to the contents view and then have the template use that.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org


More information about the Zope3-dev mailing list