File:  [Repository] / OSA_system2 / OSAS_server.py
Revision 1.8: download - view: text, annotated - select for diffs - revision graph
Sat Feb 12 13:30:31 2005 UTC (19 years, 4 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD
server adaptedCVS: ----------------------------------------------------------------------

    1: import os
    2: import os.path
    3: import stat
    4: import OSAS_helpers
    5: import xmlrpclib
    6: import bz2
    7: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
    8: from Globals import InitializeClass,package_home
    9: from OFS.SimpleItem import SimpleItem
   10: 
   11: 
   12: 
   13: 
   14: class OSAS_storeOnlineServer(SimpleItem):
   15:     """Server for store Online system"""
   16:     
   17:     
   18:     meta_type="OSAS_server"
   19: 
   20:   
   21:     def findIndexMeta(self,realPath=""):
   22:         """finde Rueckwaerts im Baum von Pfad ausgehend, dass erste index.meta file
   23:         @keyword path: default ist "", Pfad auf das Object
   24:         @return: None falls kein index.meta existiert sonst Pfad auf das index.meta
   25:         """
   26:         
   27:         #suche index.meta
   28:         while (not os.path.exists(os.path.join(realPath,'index.meta'))) and (not ((realPath=="") or (realPath=="/"))):
   29:             realPath=os.path.split(realPath)[0]
   30:             
   31:         if realPath=='' or realPath=='/':
   32:             if os.path.exists(os.path.join(realPath,'index.meta')):
   33:                 return (os.path.join(realPath,'index.meta'))
   34:             else:
   35:                 return None
   36:         else:
   37:             return os.path.join(realPath,'index.meta')
   38: 
   39:     def findIndexMetaWithStats(self,path=""):
   40:         """finde Rueckwaerts im Baum von Pfad ausgehend, dass erste index.meta file
   41:         @keyword path: default ist "", Pfad auf das Object
   42:         @return: None falls kein index.meta existiert sonst Tupel (Pfad auf das index.meta,stats(indexMeta)
   43:         """
   44: 
   45:         indexMeta=self.findIndexMeta(path)
   46:         if indexMeta:
   47:             return (indexMeta,self.getStat(indexMeta))
   48:         else:
   49:             return (None,[])
   50: 
   51: 
   52:     def getStat(self,path=""):
   53:         """Gibt stat von path aus
   54:         @keyword path: default ist "", Pfad
   55:         @return: stat[path]"""
   56: 
   57:         if not os.path.exists(path):
   58:             #return None,"(ERROR) path %s does not exist."%path
   59:             return None
   60:         else:
   61:             return [x for x in os.stat(path)]
   62:             
   63:             
   64:             
   65: 
   66:     def listdir(self,path=""):
   67:         """list dir"""
   68:         return os.listdir(path)
   69: 
   70:     def isdir(self,path=""):
   71:         """list dir"""
   72:         return os.path.isdir(path)
   73: 
   74:     def isfile(self,path=""):
   75:         """list dir"""
   76:         return os.path.isfile(path)
   77: 
   78: 
   79: 
   80:     def getFile(self,path):
   81:         """getFile"""
   82: 
   83:         if not os.path.exists(path):
   84:             return None
   85: 
   86:         f=file(path,'r')
   87:         
   88:         ret=f.read()
   89: 
   90:         f.close()
   91:         
   92:         return ret
   93: 
   94:     def getAllIndexMetasOfSubDirs(self,path):
   95:         """get all index Metas"""
   96:         ret={}
   97:         if os.path.exists(path+"/index.meta"):
   98:             compressed=file(path+"/index.meta","r").read()
   99:             ret["."]=('OSAS_dir',compressed)
  100:         for dir in os.listdir(path):
  101:             fileType=OSAS_helpers.checkOSASFileType(os.path.join(path,dir))
  102:             if os.path.exists(os.path.join(path,dir,"index.meta")):
  103:                 compressed=file(os.path.join(path,dir,"index.meta"),"r").read()
  104:                 ret[dir]=('OSAS_dir',compressed)
  105:             else:
  106:                 ret[dir]=(fileType,None)
  107:         return ret
  108: 
  109:                               
  110:         
  111: def manage_addOSAS_storeOnlineServerForm(self):
  112:     """interface for adding the OSAS_storeOnline"""
  113:     pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addStoreOnlineServer.zpt')).__of__(self)
  114:     return pt()
  115: 
  116: def manage_addOSAS_storeOnlineServer(self,id,RESPONSE=None):
  117:     """add the OSAS_storeOnline
  118:     @param id: id
  119:     """
  120:     newObj=OSAS_storeOnlineServer(id)
  121:     self._setObject(id,newObj)
  122:     if RESPONSE is not None:
  123:         RESPONSE.redirect('manage_main')
  124: 

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