[Zope] Strange error with Photo Product

Dieter Maurer dieter@handshake.de
Tue, 16 Jul 2002 20:03:24 +0200


Dennis Allison writes:
 > > > ...
 > > > Zope Error
 > > > Zope has encountered an error while publishing this resource.
 > > > Error Type: KeyError
 > > > Error Value: the_file
 > > > 
 > > > ...
 > > > 
 > > >  File /var/zope/lib/python/Products/PythonScripts/PythonScript.py, line
 > > > 302, in _exec
 > > >     (Object: photo_upload)
 > > >     (Info: ({'script': <PythonScript instance at 8b70a88>, 'context':
 > > > <Folder instance at 8d91b60>, 'container': <Folder instance at 8d91b60>,
 > > > 'traverse_subpath': []}, (), {}, None))
 > > >   File Script (Python), line 8, in photo_upload
 > > >   File /var/zope/lib/python/AccessControl/ZopeGuards.py, line 90, in
 > > > guarded_getitem
 > > >   File /var/zope/lib/python/ZPublisher/HTTPRequest.py, line 847, in
 > > > __getitem__
 > > > KeyError: (see above) File
 > ...
 > The form, a DTML-Method:
 > ------------------------------------------------------------------------
 > 
 > <dtml-var standard_html_header>
 > <p>
 > <form action="photo_upload" method="POST" enctype="multipart/form-data">
 >    <input type="file"  name="the_file" size="30">
 >    <br>
 >    <input type=submit name=submit value="Upload Photo">
 > </form>
 > <p>
 > <dtml-var standard_html_footer>
 > ------------------------------------------------------------------------
 > 
 > 
 > The handler, a Python Script:
 > ------------------------------------------------------------------------
 > 
 > request = container.REQUEST
 > RESPONSE =  request.RESPONSE
 > # move to photofolder 
 > p = container.restrictedTraverse('Photos')
 > if( not p ): raise AssertionError, 'No Place to store Photos'
 > the_id = container.genUID()
 > the_title = 'My Photo'
 > the_file = request['the_file']
 > p.manage_addProduct['Photo'].manage_addPhoto( the_id, the_title, the_file, engine='PNG')
 > request['RESPONSE'].redirect( request['URL'] )
The problem happens in the redirect!

    When the redirect is executed (again by "photo_upload"), the
    request object is (essentially) empty.


Dieter