Re: [Zope] Zope/python: downloading images from the web and add them to Zope]

2005-04-08 Thread Cliff Ford
[EMAIL PROTECTED] wrote:
I would like to know how to add image file from an URL. I created a
form with to pissibilities: add an image from a local file , and a
image from an url
You can get an image from a url with an External Method:
# Get an image using the original url.
import urllib
def getImage(url):
f = urllib.urlopen(url)
data = f.read()
f.close()
return data
Hope this is enough to put you on track.
Cliff
here is my form:  get from disk: 

 get from the internethttp://www.monsite.fr/monimage.jpg"; disabled="disabled">
This form call a python script:
if REQUEST.sourcePict=="file": 
pathImgs.manage_addProduct['OFSP'].manage_addImage("pict_"+id,
REQUEST.pict_file, title="pictogramme metier", precondition="",
content_type="") else: 
pathImgs.manage_addProduct['OFSP'].manage_addImage("pict_"+id,
REQUEST.pict_internet, title="pictogramme metier", precondition="",
content_type="")

With a locl file it works (case sourcePict=file), but when I want to
add images from an url, it doesn't work. I suppose that the second
parameter of manage_addImage must be a file type.In the first case,
it works , but in the second, the parameter passed is a string
(complete url of the image). so how to do?
thanks for your answers and excuse me for the lack in English (I'm
french) ___ 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 )

___
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 )


[Zope] Zope/python: downloading images from the web and add them to Zope

2005-04-08 Thread BonviciniJ
I would like to know how to add image file from an URL.
I created a form with to pissibilities: add an image from a local file , and a 
image from an url

here is my form:

get from disk: 




get from the internethttp://www.monsite.fr/monimage.jpg"; disabled="disabled">

This form call a python script:

if REQUEST.sourcePict=="file":
 pathImgs.manage_addProduct['OFSP'].manage_addImage("pict_"+id, 
REQUEST.pict_file, title="pictogramme metier", precondition="", content_type="")
else:
pathImgs.manage_addProduct['OFSP'].manage_addImage("pict_"+id, 
REQUEST.pict_internet, title="pictogramme metier", precondition="", 
content_type="")


With a locl file it works (case sourcePict=file), but when I want to add images 
from an url, it doesn't work.
I suppose that the second parameter of manage_addImage must be a file type.In 
the first case, it works , but in the second, the parameter passed is a string 
(complete url of the image).
so how to do?

thanks for your answers and excuse me for the lack in English (I'm french)
___
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 )