[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 =
'src="http://localhost/++skin++Application/000001/0001/1/photo"'
  >>> imgTag in user.contents
  True

Regards
Roger Ineichen
_____________________________
END OF MESSAGE

> Best regards,
> Darryl Cousins



More information about the Zope3-users mailing list