[Zope] overwriting images revisited

Li Dongfeng mavip5@inet.polyu.edu.hk
Wed, 15 Dec 1999 10:54:38 +0800


Darcy Clark wrote:
> 
> I have trolled through the mailing list archives (wish this stuff was in
> the docs!!), I found some references to the use of manage_addImage and
> the manage_upload methods....just enought o get myself into trouble it seems.
> 
> I have a form that prompts users for
> 
> <input type="text" name="id" size="20">
> <input type="file" name="image">
> 
> i.e.  id is the name of image, and file is the file to be uploaded to
> Zope. the action of this form is the added_new_staff method below :
> 
> <dtml-with REQUEST>
> <dtml-with form>
> <dtml-if "REQUEST.has_key('image')">

I think the problem is here. Can REQUEST.has_key
decide whether you have a image object named 'image'
in your current folder? What is the folder you 
want to add to anyway?

I'm not sure how to work around this,
I usually give the exact folder name to add to.

>         <dtml-if "(REQUEST.image.seek(0, 2) or REQUEST.image.tell()) > 0">
>                 <!-- if no image is found -->
>                 <!--#call "manage_addImage(REQUEST['id'],REQUEST['image'],'')"-->
>         <dtml-else>
>                 <!-- if image is found and needs to be overwritten -->
>                 <dtml-with "_[id]">
>                         <!--#call "manage_upload(REQUEST['id'],REQUEST['image'])"-->
>                 </dtml-with>
>         </dtml-if>
> </dtml-if>
> </dtml-with>
> </dtml-with>
> 
> if the image doesn't exist, then it is uploaded through manage_addImage
> - this part works well. But if the image is found, then unfortnately the
> manage_upload doesn't work for me. I get the error :
> 
> Error Type: Bad Request
> Error Value: The id test is invalid - it is already in use.
> 
> I would like to be able to overwrite existing images. Am I making any
> obvious mistakes here ?
> 
> thanks for any help,
> 
> Darcy
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> 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 )