[Zope] ExternalMethod for exporting un-pickled Office files to the filesystem etc

2006-06-22 Thread michael nt milne
HiJust wondering if anyone has written or attempted to write a script which would read through a site built using Zope and write all attached/uploaded files (Word, PDF, Excel) etc to a filesystem location in an un-pickled format. Therefore the files would be usable by their native application and be accessible outside of Zope. The business logic behind this is to be able to create, say once a day at night, a copy of all digital business assets for extra back-up and recovery purposes in case of disaster. Also this would be good for migration purposes if required.
If not, how long would it take to create such a script? I could probably source a sponsor for it. I realise that it's best to do this at the application level and at the moment this would be through Plone.
I've demoed all the Plone external storage products and also checked out DirectoryStorage but all these store pickled files etc.
Thanks-- michael

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


Re: [Zope] ExternalMethod for exporting un-pickled Office files to the filesystem etc

2006-06-22 Thread Tino Wildenhain

michael nt milne schrieb:

Hi

Just wondering if anyone has written or attempted to write a script 
which would read through a site built using Zope and write all 
attached/uploaded files (Word, PDF, Excel) etc to a filesystem location 
in an un-pickled format. Therefore the files would be usable by their 
native application and be accessible outside of Zope. The business logic 
behind this is to be able to create, say once a day at night, a copy of 
all digital business assets for extra back-up and recovery purposes in 
case of disaster. Also this would be good for migration purposes if 
required.


If not, how long would it take to create such a script? I could probably 
source a sponsor for it. I realise that it's best to do this at the 
application level and at the moment this would be through Plone.


I've demoed all the Plone external storage products and also checked out 
DirectoryStorage but all these store pickled files etc.


--- snip --
import os
import sys

try:
targetdir=sys.argv[1]
except IndexError:
print usage: zopectl run %s target dirrectory % sys.argv[0]

def filedump(resulttuple,basedir):
pathname,fileobject=resulttuple
print dumping %s (%d Bytes) % (fileobject.getId(),fileobject.size)

o=open(os.path.join(basedir,pathname.replace('/','_')+fileobject.getId()),wb)
o.write(str(fileobject.data))


for res in app.ZopeFind(app,obj_metatypes=['File'])
filedump(res,targetdir)


- snip ---

and run this over ZEO via zopectl run thescript.py somewhere/to/targetdir


There are possibly many improvements (creating subdirectories, fixing extensions
and so on)

Regards
Tino Wildenhain


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


Re: [Zope] ExternalMethod for exporting un-pickled Office files to the filesystem etc

2006-06-22 Thread michael nt milne
Cheers, thanks a lot for that. I'll give it a go. I still may be interested in sponsoring a version with the improvements you mention etc and possibly more. Would that code be compatible for Unix and also for Windows NTFS?
ThanksOn 6/22/06, Tino Wildenhain [EMAIL PROTECTED] wrote:
michael nt milne schrieb: Hi Just wondering if anyone has written or attempted to write a script which would read through a site built using Zope and write all attached/uploaded files (Word, PDF, Excel) etc to a filesystem location
 in an un-pickled format. Therefore the files would be usable by their native application and be accessible outside of Zope. The business logic behind this is to be able to create, say once a day at night, a copy of
 all digital business assets for extra back-up and recovery purposes in case of disaster. Also this would be good for migration purposes if required. If not, how long would it take to create such a script? I could probably
 source a sponsor for it. I realise that it's best to do this at the application level and at the moment this would be through Plone. I've demoed all the Plone external storage products and also checked out
 DirectoryStorage but all these store pickled files etc.--- snip --import osimport systry: targetdir=sys.argv[1]except IndexError: print usage: zopectl run %s target dirrectory % 
sys.argv[0]def filedump(resulttuple,basedir): pathname,fileobject=resulttuple print dumping %s (%d Bytes) % (fileobject.getId(),fileobject.size) o=open(os.path.join(basedir,pathname.replace
('/','_')+fileobject.getId()),wb) o.write(str(fileobject.data))for res in app.ZopeFind(app,obj_metatypes=['File']) filedump(res,targetdir)- snip ---
and run this over ZEO via zopectl run thescript.py somewhere/to/targetdirThere are possibly many improvements (creating subdirectories, fixing extensionsand so on)RegardsTino Wildenhain
-- michael
___
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 )


Re: [Zope] ExternalMethod for exporting un-pickled Office files to the filesystem etc

2006-06-22 Thread Tino Wildenhain

michael nt milne schrieb:
Cheers, thanks a lot for that. I'll give it a go. I still may be 
interested in sponsoring a version with the improvements you mention etc 
and possibly more. Would that code be compatible for Unix and also for 
Windows NTFS?


at the moment, yes ( using os.path.join() for that)

directory creating isnt that hard either, its just some recursion
and checking...

Regards
TIno Wildenhain
___
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 )