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
        
###############################



_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to