[Zope] Get files from the disk

Tino Wildenhain tino@wildenhain.de
Wed, 08 Aug 2001 13:31:35 +0200


Hi,

--On Mittwoch, 8. August 2001 12:42 +0200 Herve Coatanhay <hcoatanhay@virtual-net.fr> wrote:

> ruben wrote:
>
>> Hello.
>>
>> I have a new and big problem
>> I'm migrating of IIS to Zope, but now in a directory of de old web I have a
>> lot of images (over 8.000).
>>
>> Do you now how can I?
>>
>> 1- Put all this files to zope at the same time. (Not one to one)
>>
>> or
>>
>> 2- Do that Zope read directly from the hard disk. I would prefer this
>> option.
>>
>>
>> Thanks.
>
> For 2 : use an external method in Python that returns an image:
>
> def get_external_image(self,filename,REQUEST,RESPONSE):
>      if not os.path.exists(filename):
>         return ""
>
>      fptr=3Dopen(filename, "rb")
>      data=3Dfptr.read()
>      size=3Dlen(data)
>      fptr.close()
>
>      RESPONSE.setHeader("Content-Type", "image/png")
>      RESPONSE.setHeader("Content-Length",size)
>
>      return data
>
> for PNG images
>

Erm... looks like a big memory hoog. I would not recommend this.
If its really (really!) nessecary, one could use one of the
various extfile products on zope.org.

However, importing them to the Zodb seems to be the prefered solution
as you can do a lot more with it (like set titles (used for alt-attribute))
ask for width and height and even for existence.

Regards
Tino
> --
> Herv=E9 Coatanhay
>
>
>
> _______________________________________________
> 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 )