[Zope3-Users] Re: help with directlyProvides

Florent Guillaume fg at nuxeo.com
Sun May 7 19:41:27 EDT 2006


luis wrote:
> Jean-Marc Orliaguet wrote:
> 
>> luis wrote:
>>
>> are you sure? I tried with:
>>
>> jmo at localhost ~/Zope3/src $ python2.4
>> Python 2.4.2 (#1, Dec  4 2005, 15:28:38)
>> Type "help", "copyright", "credits" or "license" for more information.
>>  >>> from zope.app.file import file
>>  >>> f = file.File()
>>  >>> f
>> <zope.app.file.file.File object at 0xb7cbad2c>
>>  >>> import zope.interface
>>  >>> class IMarker(zope.interface.Interface):
>> ...          """Marker interface"""
>> ...
>>  >>> zope.interface.directlyProvides(f, IMarker)
>>  >>> list(zope.interface.directlyProvidedBy(f))
>> [<InterfaceClass __main__.IMarker>]
>>  >>> IMarker.providedBy(f)
>> True
> 
> yes.. that's why I say that it seems very strange... the call to
> directlyProvides works as you show with your example, ... *but*, after you
> add your file to a folder, something removes the IMarker interface (or it
> doesn't get saved for some reason )

That would be a bug in the container framework, something using 
directlyProvides instead of alsoProvides. What version of Zope 3 are you 
using? I think I remember something being fixed in that area.

Florent

> 
> directlyProvides( f, IMarker )
> if not IMarker.providedBy( f ):
>         raise Error
> myfolder['f'] = f
> 
> if you put something like that in an Adding-Form, no exception is raised and
> the object "f" is added to the container. so the directlyProvides does
> work...but then, if you take a look at the object "f" in the zmi
> introspector, you will see something like:
>         
>         DirectlyProvided interfaces
>                 <nothing>
> 
> so what I'm saying is not that directlyProvides doesnt work, but that
> provided-list gets lost somewhere on the way into the database... (but if f
> is  a Folder, then the provided-list is kept )
> 
> luis
> 
> 


-- 
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com


More information about the Zope3-users mailing list