Re: [Zope] External Method not accepting CGI module

2000-07-11 Thread Dieter Maurer

Kelvin Cheong writes:
  import cgi
  
  form = cgi.FieldStorage()
This gives you an empty "FieldStorage"
  
  fileitem = form["userTABPIX1"]
In it, "userTABPIX1" is unknown.
  
   fname = tempfile.mktemp()
   fp=open(fname,'w')
   fp.write(fileitem.file.read())
   fp.close()
Give your external method either the first argument "self"
or an argument "REQUEST".

In the first case, you can use "REQUEST=self.REQUEST" to
get the REQUEST object. In the second case, you use
REQUEST directly.

"REQUEST.form" contains the form variables of the REQUEST.



Dieter

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




[Zope] External Method not accepting CGI module

2000-07-10 Thread Kelvin Cheong


Dear All,

I have this python module for uploading an image from a client to the
server (which would be subsequently inserted into a MySQL database, which
is still on the midst of being resolved). I''m trying to import this into
Zope as an External MEthod. It's contents are as follows :



import cgi

form = cgi.FieldStorage()

fileitem = form["userTABPIX1"]

fname = tempfile.mktemp()
fp=open(fname,'w')
fp.write(fileitem.file.read())
fp.close()



However, Zope generates this error :

Zope has encountered an error while publishing this resource.

Error Type : KeyError
Error Value: userTABPIX1


Apparently, this piece of code is supposed to work. I grabbed it off the
mailing list, and I've compared with the python references and tutorials. 

Is it because it's not meant to be used as an External MEthod? 

If so, can anybody suggest a way for me to upload files from the client to
the server which will subsequently be inserted into a mySQL db?


I posted another message in the archive earlier on which describes my
previous attempts in inserting an image into the mySQL database from a
form.



Thanx,
k.c.

VCN - The Leader In Corporate Communication Solutions
Visit our website at http://www.vcn.com.my. 
or http://www.vcnlinux.com


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