Annotation of OSA_system2/OSAS_server.py, revision 1.3
1.1 dwinter 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
1.3 ! dwinter 7:
1.1 dwinter 8: import OSAS_helpers
9: from OSAS_helpers import *
10:
11: class OSAS_storeOnlineServer(SimpleItem):
12: """Server for store Online system"""
1.2 dwinter 13:
14: _v_metaFiles={} #chache fuer indexMeta
15: meta_type="OSAS_server"
16:
17:
1.1 dwinter 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:
1.3 ! dwinter 67: def getFile(self,path):
! 68: """getFile"""
! 69: f=file(path,'r')
! 70: ret=f.read()
! 71: f.close()
! 72: return ret
! 73:
1.1 dwinter 74: def manage_addOSAS_storeOnlineServerForm(self):
75: """interface for adding the OSAS_storeOnline"""
76: pt=PageTemplateFile(os.path.join(package_home(globals()),'zpt','addStoreOnlineServer.zpt')).__of__(self)
77: return pt()
78:
79: def manage_addOSAS_storeOnlineServer(self,id,RESPONSE=None):
80: """add the OSAS_storeOnline
81: @param id: id
82: """
83: newObj=OSAS_storeOnlineServer(id)
84: self._setObject(id,newObj)
85: if RESPONSE is not None:
86: RESPONSE.redirect('manage_main')
87:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>