[Zope3-dev] Re: Container interface issues
Garrett Smith
garrett at mojave-corp.com
Wed Sep 10 11:18:08 EDT 2003
Jim Fulton wrote:
> Anthony Baxter wrote:
>
>>>>> Jim Fulton wrote
>>>
>>>
>>> I proposed that application code, rather than containers, be
>>> responsible for generating events and calling necessary hooks when
>>> adding or removing objects.
>>
>>
>>
>> I understand the rationale for it (indeed, I can't see a better way) but
>> this makes me uneasy. In the process of hooking up the catalog I found a
>> number of existing places that were not Doing The Right Thing with event
>> generation - making more places to do this Would Be Bad. Tracking down
>> missing event generation stuff also sucks - things are just wacky, and
>> it takes some time to find the problem.
>
>
> I suspect that this would be almost as likely of Doing The Right Thing
> was the container's responsibility.
>
> I think we can arrange for making Doing The Right Thing easier. For
> example,
> instead of:
>
> container.setObject(name, object)
>
> people will use:
>
> zapi.add(container, name, object)
>
> I think that these are of comparable difficulty.
I would expect to see an adapter used here:
container = zapi.getAdapter(container, IStandardNotifyContainer)
container[name] = object
This way, notification policies could be encapsulated in specific
adapters. There would be little impact on existing code since containers
are usually 'adapted' to IZopeContainer. It also provides a simple
pattern for implementing alternative notification schemes.
I personally would not be comfortable with zapi.add because of its opacity.
-- Garrett
More information about the Zope3-dev
mailing list