[Zope] Uploading lots of little files to zope

Bruce Eckel Bruce@EckelObjects.com
Fri, 21 Dec 2001 00:35:44 -0800


Never mind. I figured it out -- this is crude and hackish (I'm
using fixed file and directory names), but if someone else needs
the same answer, it's a start.

import zipfile, StringIO

def unzip(self):
  result = ''
  source = self.restrictedTraverse('book.zip')
  zf = zipfile.ZipFile(StringIO.StringIO(source.data))
  for zi in zf.infolist():
    if zi.filename.endswith('/'): continue
    result += zi.filename + '\n'
    data = zf.read(zi.filename)
    name = zi.filename.split('/')[-1]
    self.book.manage_addProduct['OFSP'].manage_addDTMLDocument(name,
 title=name, file=data)
  return result


*********** REPLY SEPARATOR  ***********

On 12/20/01 at 8:31 PM Bruce Eckel wrote:

>I now have lots of little files -- thousands -- to upload to Zope
>every time I do an update of a book. FTP-ing is quite painful. Is
>there some better solution; is there a way to upload a zip file
and
>then expand it? Or is that something I must write an external
>method to do?
>
>Thanks...
>
>Most current information can be found at:
>http://www.mindview.net/Etc/notes.html
>===================
>Bruce Eckel    http://www.BruceEckel.com
>Contains free electronic books: "Thinking in Java 2e" & "Thinking
>in C++ 2e"
>Please subscribe to my free newsletter -- just send any email to:
>join-eckel-oo-programming@earth.lyris.net
>My schedule can be found at:
>http://www.mindview.net/Calendar
>===================
>
>
>
>_______________________________________________
>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 )



Most current information can be found at:
http://www.mindview.net/Etc/notes.html
===================
Bruce Eckel    http://www.BruceEckel.com
Contains free electronic books: "Thinking in Java 2e" & "Thinking
in C++ 2e"
Please subscribe to my free newsletter -- just send any email to:
join-eckel-oo-programming@earth.lyris.net
My schedule can be found at:
http://www.mindview.net/Calendar
===================