[Zope3-Users] testbrowser and file upload
darryl at darrylcousins.net.nz
Mon Jul 3 23:24:02 EDT 2006
Yes that works. Following the same line of thinking it also works when I
give control.filename a value **before** I assign control.value. Apparently the
content_type doesn't need to be set.
>>> control.filename = 'myPhoto.gif'
>>> control.value = myPhoto
I should have thought of this when looking at the file_add method
(previously I'd tried setting control.filename **after** setting the
Thanks for the advice.
On Tue, 2006-07-04 at 01:59 +0200, dev at projekt01.ch wrote:
> 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
> END OF MESSAGE
> > Best regards,
> > Darryl Cousins
More information about the Zope3-users