[Zope] External cgi - filesystem

Philippe Jadin philippe.jadin@123piano.com
Sat, 7 Jul 2001 19:44:49 +0200


Hello,

I'm becoming crazy ;-) so I hope my question will be somewhat clear.

I'd like to create an external method that get's a zope image object, write
it to the filesystem (1), execute an external executable on it (2), and put
a resulting file back into zope (3). All this to convert a jpg file to a swf
flash file using swift-generator ( www.swift-tools.com fyi)

Maybe there are others way to use external cgi with zope and convert to
flash, but I have no idea (suggestions welcome!)

so my method is like this :

---------
def filewrite(self, original_id):
#simply testing how to write a file out of zope onto filesystem.

  import os, string
  from tempfile import mktemp
  from cStringIO import StringIO

# stolen from the thumbnail example of the zopebook :
  source_image=getattr(self, original_id)
  source_file=StringIO(source_image.data)

  REQUEST=self.REQUEST

  #create temporary filenames .in
  file1=mktemp()+ ".in"
  file2=mktemp()+ ".out"
  f=open(file1,"w")
  f.write(source_file.getvalue())
  f.close()
# that was part (1)

# part (2)
#  os.system("myexternal_soft.exe "+file1+" > "+file2)
#  f=open(file2,"rt")
#  lines=f.readlines()
#  f.close();
#  os.unlink(file1)
#  os.unlink(file2)
-------------

Questions :

- the first part almost work : I can write an image file to disk if I supply
a correct original_id parameter. _BUT_, the file written on disk is
corrupted (it's 131 bytes bigger...)

- of course I didn't try yet to execute my exe on this file because it is
somewhat corrupted, but it *should* work

- part (3) is probably not too hard, reading the file outputed by the
executable, and doing some sort of manage add product... but if you ave any
clue;-)

What am I doing wrong? Why do I get strange filesizes? Am I stupid? Those
are my today's questions.

Thanks a lot !


Philippe Jadin
www.123piano.com