[Zope3-dev] help with directlyProvides

luis lparrab at gmx.net
Thu May 4 19:10:01 EDT 2006


Hi all,

I asked this a while ago in the zope3.user list but had no luck, so I'll try
it here now..

I'm having problems getting interface.directlyProvides to work...
does anyone know why the following code doesn't work (file is created, but
it doesnt provide the IMarker interface...)

thanks and regards,
luis

###########
class IMarker(interface.Interface):
    """ marker test interface """
    
class IFileUpload(interface.Interface):
    """ schema for uploading files"""
    file = schema.Bytes(
        title=u"File",
        required=True)

class AddFileForm(form.AddForm):
    """ Add """
    form_fields = form.Fields(IFileUpload)
    
    def create(self, data):
        file = File(data = data['file'])

        # >>>>>>>  this is not working, 
        # the providedBy-check pases, so I guess the interface
        # is "assigned" but then somehow "forgotten" before the object
        # gets saved ( according to the introspector )

        interface.directlyProvides(file, IMarker ) 
        if not IMarker.providedBy(file):
            raise TypeError('directly provides failed')
        
        return file
        
###############################





More information about the Zope3-dev mailing list