[Zope3-Users] Contained File object
Dominik Huber
dominik.huber at projekt01.ch
Tue Jan 18 04:34:56 EST 2005
Hi Tom,
>
> Should zope.app.file.File implement IContained? Why / Why not?
> Here's a comparison b/w adding a Folder and File...
The container framework does not require mandatory ILocation or
IContained for its containment. In absent of ILocation or IContained a
contained proxy is used (comparable to zope 2's context wrappers) to
provided
IContained. (See ../src/zope/app/container/contained.py -> function
containedEvent())
Example:
An object providing IContained can be called both ways:
>>> root['folder'] = folder = Folder()
>>> zapi.getName(folder)
u'b'
>>> zapi.getName(root['folder'])
u'b'
An object that does not provid IContained. Has a different behavior.
Calling the original object whitout the contained proxy:
>>> root['file'] = file = File()
>>> zapi.getName(file)
Traceback (most recent call last):
...
TypeError: ('Could not adapt', <zope.app.file.file.File object at
0x00E23970>, <
InterfaceClass zope.app.traversing.interfaces.IPhysicallyLocatable>)
Calling the contain proxied object:
>>> zapi.getName(root['file'])
u'a'
Regards,
Dominik Huber
Projekt01 GmbH
_____________________________
END OF MESSAGE
More information about the Zope3-users
mailing list