Diff for /ECHO_content/ECHO_collection.py between versions 1.274 and 1.275

version 1.274, 2006/09/10 11:03:07 version 1.275, 2006/10/18 14:42:33
Line 18  except: Line 18  except:
 import urlparse  import urlparse
 import string  import string
 import tempfile  import tempfile
   import zipfile
 import re  import re
 import os  import os,shutil
 import OFS.Image  import OFS.Image
 from types import *  from types import *
 from OFS.Cache import Cacheable  from OFS.Cache import Cacheable
Line 1921  class ECHO_collection(CatalogAware, Fold Line 1922  class ECHO_collection(CatalogAware, Fold
   
     path="/mpiwg/online/permanent/shipbuilding"      path="/mpiwg/online/permanent/shipbuilding"
   
       
       def exportImportObjects_html(self,RESPONSE):
           """ImportObject"""
           pt=zptFile(self, 'zpt/exportImportObjects.zpt')
           pt.content_type="text/html"
           return pt()
           
       def importObjects_html(self,RESPONSE):
           """ImportObject"""
           pt=zptFile(self, 'zpt/importObjects.zpt')
           pt.content_type="text/html"
           return pt()
      
       def importObjects(self,zfile,RESPONSE=None,REQUEST=None):
           """import object from file"""
           
           zf=zipfile.ZipFile(zfile,"r")
           tmpdir=tempfile.mkdtemp() # create tempdir
           ret=None
           
           for name in zf.namelist():
                  fn=tempfile.mkstemp()[1]
                  tf=file(fn,"w")
                  x=zf.read(name)
                  tf.write(x)
                  tf.close()
                  try:
                      self._importObjectFromFile(fn,set_owner=1)
                  except:
                      if not ret:
                          ret=""
                      ret+="Cannot import: %s (Already existing?)<br>"%name
                  os.remove(fn)
           
           if ret:
               return """<html><body>%s</body></html>"""%ret
           if RESPONSE:
               RESPONSE.redirect(self.absolute_url())
           
       def exportObjects_html(self,RESPONSE):
           """Export objects"""
           
           pt=zptFile(self, 'zpt/exportObjects.zpt')
           pt.content_type="text/html"
           return pt()
       
       def exportObjects(self,ids,RESPONSE=None):
           """export objects with type id"""
           if not (type(ids) is ListType):
               ids=[ids]
           
           tmpdir=tempfile.mkdtemp() # create tempdir
           objs=self.ZopeFind(self,obj_ids=ids)
           tmpfile=tempfile.mkstemp()[1]
   
           zf=zipfile.ZipFile(tmpfile,"w")
           for obj in objs:
   
               f = os.path.join(tmpdir, '%s.zexp' %obj[0])
               #print E.absolute_url()
   
               obj[1]._p_jar.exportFile(obj[1]._p_oid, f)
   
               zf.write(f,obj[0])
           
           zf.close()
           shutil.rmtree(tmpdir)
           if RESPONSE:
               RESPONSE.setHeader("Content-Type","application/octet-stream")
               len=os.stat(tmpfile)[6]
               RESPONSE.setHeader("Content-Length",len)
               RESPONSE.setHeader("Content-Disposition","""attachement; filename=%s"""%"export.zip")
               fh=file(tmpfile)
               for x in fh.read():
                   RESPONSE.write(x)
               fh.close()
               
     def getMDValueSimpleSearchField(self):      def getMDValueSimpleSearchField(self):
           """returns value for simple search"""            """returns value for simple search"""
           return " ".join([self.title,self.description])            return " ".join([self.title,self.description])
Line 2494  class ECHO_collection(CatalogAware, Fold Line 2572  class ECHO_collection(CatalogAware, Fold
         {'label':'Localize','action':'localizeObjects'},          {'label':'Localize','action':'localizeObjects'},
         {'label':'Change Weights','action':'changeWeights'},          {'label':'Change Weights','action':'changeWeights'},
         {'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'},          {'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'},
           {'label':'Export/Import Objects','action':'exportImportObjects_html'},
         {'label':'Graphic Coords','action':'ECHO_graphicEntry'},          {'label':'Graphic Coords','action':'ECHO_graphicEntry'},
         {'label':'create resources from XML','action':'createRessourcesFromXMLForm'},          {'label':'create resources from XML','action':'createRessourcesFromXMLForm'},
         {'label':'Set Startpage','action':'setStartpageFolderForm'},          {'label':'Set Startpage','action':'setStartpageFolderForm'},

Removed from v.1.274  
changed lines
  Added in v.1.275


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>