[Zope] Accessing file object to upload in an external method

2005-05-26 Thread Simon ALEXANDRE
Hi,

I'm new in zope and I'm trying to upload a file on zope using localfs. 
I already done it through a little basic html page + python script.

I would like now use it in an external method.

Here is the line added in the external method: 

self.dir_filesystem.manage_upload(file=self.zipfile)

zipfile is the name of the file in the html form (File INPUT TYPE=file
NAME=zipfile SIZE=25 VALUE=)

I got the following error: 

File D:\\D-Side/qross/zope_gui\Extensions\Project.py, line 31, in
PrepareToCreateOrUpdateObject
self.dir_filesystem.manage_upload(file=self.zipfile)
 exceptions.AttributeError: zipfile

I'm quite sure that my error lies in the way I reference 'zipfile' but I
don't know how to proceed

Thanks for your help

Simon


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Accessing file object to upload in an external method

2005-05-26 Thread J Cameron Cooper

Simon ALEXANDRE wrote:

I'm new in zope and I'm trying to upload a file on zope using localfs. 
I already done it through a little basic html page + python script.


I would like now use it in an external method.

Here is the line added in the external method: 


self.dir_filesystem.manage_upload(file=self.zipfile)

zipfile is the name of the file in the html form (File INPUT TYPE=file
NAME=zipfile SIZE=25 VALUE=)

I got the following error: 


File D:\\D-Side/qross/zope_gui\Extensions\Project.py, line 31, in
PrepareToCreateOrUpdateObject
self.dir_filesystem.manage_upload(file=self.zipfile)
 exceptions.AttributeError: zipfile

I'm quite sure that my error lies in the way I reference 'zipfile' but I
don't know how to proceed


Two questions to ask yourself: what is 'self' and where would 'zipfile' be?

Since we're not in the same room, I'll answer:

'self' is the object that the method is called on.
'zipfile' is present in the request, since it comes from a form.

How would data from the request be available through the object you 
called the method on? But: you can get the request from the context::


 self.request.zipfile

should work.

--jcc

--
Building Websites with Plone
http://plonebook.packtpub.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Accessing file object to upload in an external method

2005-05-26 Thread Dieter Maurer
Simon ALEXANDRE wrote at 2005-5-26 10:37 +0200:
 ...
Here is the line added in the external method: 

self.dir_filesystem.manage_upload(file=self.zipfile)

zipfile is the name of the file in the html form (File INPUT TYPE=file
NAME=zipfile SIZE=25 VALUE=)

As all request parameters (such as form controls), it is
part of the request object.

Therefore, you access it with self.REQUEST['zipfile'].

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )