[Zope3-Users] testbrowser and file upload

dev at projekt01.ch dev at projekt01.ch
Mon Jul 3 19:59:57 EDT 2006

Hi Darryl

> I have found a strange behaviour with testbrowser and file 
> objects. What appears to happen is that the 
> cStringIO.StringIO that I pass to the file control in a form 
> is converted to unicode before reaching the view handler. 
> This then raises AttibuteError: Unicode has no read attribute.


Try something like that:

  >>> import StringIO
  >>> myPhoto = StringIO.StringIO('my photo')
  >>> control = user.getControl(name='photoForm.photo')
  >>> fileControl = control.mech_control
  >>> fileControl.add_file(myPhoto, filename='myPhoto.gif')
  >>> user.getControl(name='photoForm.actions.add').click()
  >>> imgTag =
  >>> imgTag in user.contents

Roger Ineichen

> Best regards,
> Darryl Cousins

More information about the Zope3-users mailing list