Dieter Maurer wrote:

> Joh Johannsen writes:
>  > What sort of object is this "REQUEST.form['attached_file']"?   Is there some
>  > way to find out this sort of thing when you have a Python object?  (I'm new
>  > to Python)
> It is a "ZPublisher.HTTPRequest.FileUpload" object.
> >From its (source) documentation:
>     File upload objects are used to represent file-uploaded data.
>     File upload objects can be used just like files.
>     In addition, they have a 'headers' attribute that is a dictionary
>     containing the file-upload headers, and a 'filename' attribute
>     containing the name of the uploaded file.
>  > Is that even the place to look to get the name of the file on the server
>  > after it is uploaded?
> You should not rely on the fact that the data is stored somewhere
> on the server.
>  > That's why I mentioned the quote from that How-To (which the above is
>  > basically a copy of):  "In you python external method you can now reference
>  > REQUEST.form['attached_file'] as a normal file. You can perform things such
>  > as read() on the object. "
> "REQUEST.form['attached_file']" should be a "FileUpload" object
> and as such have a "read" method (beside many others).
> Thus, "REQUEST.form['attached_file'].read()" should return the
> file content.
> In an earlier message, you said, it did not.
> What happened?

What happens is that if I have this:

def get_file_name(self,REQUEST):
    s = REQUEST.form['attached_file'].filename
    contents = REQUEST.form['attached_file'].read()
    return s

I get a Zope error for the External Method, when I reload it by clicking on "edit"
Here is traceback...

Traceback (innermost last):
  File /usr/local/Zope-2.2.0-src/lib/python/ZPublisher/, line 222, in
  File /usr/local/Zope-2.2.0-src/lib/python/ZPublisher/, line 187, in
  File /usr/local/Zope-2.2.0-src/lib/python/Zope/, line 221, in
    (Object: get_file_name)
  File /usr/local/Zope-2.2.0-src/lib/python/ZPublisher/, line 171, in
  File /usr/local/Zope-2.2.0-src/lib/python/ZPublisher/, line 160, in
    (Object: manage_edit)
  File /usr/local/Zope-2.2.0-src/lib/python/ZPublisher/, line 112, in
    (Object: manage_edit)
line 201, in manage_edit
    (Object: get_file_name)
line 210, in getFunction
    (Object: get_file_name)
  File /usr/local/Zope-2.2.0-src/lib/python/App/, line 217, in
    (Info: ('/usr/local/Zope2/Extensions/', 'get_file_name'))
SyntaxError: (see above)


Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to