File:  [Repository] / OSA_system2 / OSAS_server.py
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Fri Feb 11 17:01:22 2005 UTC (19 years, 3 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD
server

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

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