changeset 41:f94fc5a51a38

Merge with 0c769ba7957ce73c2f97dc15014928df8418fdbc
author casties
date Wed, 01 Sep 2010 21:04:47 +0200
parents fbd3ce67c821 (current diff) 0c769ba7957c (diff)
children 291aed5f0e0d
files RestDbInterface.py
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/RestDbInterface.py	Wed Sep 01 21:03:08 2010 +0200
+++ b/RestDbInterface.py	Wed Sep 01 21:04:47 2010 +0200
@@ -763,19 +763,19 @@
 # End for GoogleMaps creation
 
     def RESTwrite2File(self,datadir, name,text):
-#        try:
-            fileid=name
-            if fileid in datadir.objectIds():
-                datadir.manage_delObjects(fileid)
-            newfile=open(name,'w')
-            newfile.write(text)
-            newfile.close()
-            file4Read=open(name,'r')
-            fileInZope=datadir.manage_addFile(id=fileid,file=file4Read)
-            return "Write successful"
-#        except:
-#            return "Could not write"
+        logging.debug("RESTwrite2File datadir=%s name=%s"%(datadir,name))
+        try:
+            import cStringIO as StringIO
+        except:
+            import StringIO
 
+        # make filehandle from string
+        textfile = StringIO.StringIO(text)
+        fileid=name
+        if fileid in datadir.objectIds():
+            datadir.manage_delObjects(fileid)
+        fileInZope=datadir.manage_addFile(id=fileid,file=textfile)
+        return "Write successful"
         
     def manage_editRestDbInterface(self, title=None, connection_id=None,
                      REQUEST=None):