--- OSA_system2/OSAS_browser.py 2004/12/23 08:30:55 1.2 +++ OSA_system2/OSAS_browser.py 2004/12/23 10:48:28 1.3 @@ -13,6 +13,7 @@ import os import os.path import stat import xml.dom.minidom +from types import * class OSAS_storeOnline(SimpleItem): """Webfrontend für das Storagesystem @@ -23,6 +24,7 @@ class OSAS_storeOnline(SimpleItem): security=ClassSecurityInfo() _v_fileSystem={} #chache fuer filesystem + _v_metaFiles={} #chache fuer indexMeta def __init__(self,id): """initialize a new instance""" @@ -57,11 +59,12 @@ class OSAS_storeOnline(SimpleItem): def findEntryInIndexMeta(self,path): """fragm xml zum path @param path: Pfad auf das Object relativ zum rootFolderName - @return: den Teil von Index.meta der Informationen zu path enthaelt. + @return: den Teil von Index.meta der Informationen zu path enthaelt, None wenn error. """ indexMeta=self.findIndexMeta(path) - + if not indexMeta: + return None realPath=os.path.split(indexMeta)[0] path=os.path.normpath(os.path.join(self.rootFolderName,path)) @@ -123,7 +126,13 @@ class OSAS_storeOnline(SimpleItem): if path and (path[0]==os.sep): path=path[1:] + stats=os.stat(indexMeta) + + #teste ob schon im cache + if self._v_metaFiles.has_key(indexMeta) and (self._v_metaFiles[indexMeta][0]==stats[stat.ST_MTIME]): + return self._v_metaFiles[indexMeta][1] + dom=xml.dom.minidom.parse(indexMeta) dirs=[] @@ -151,7 +160,7 @@ class OSAS_storeOnline(SimpleItem): object=os.path.join(realPath,pathX,name) ret[object]=(fileType,'') - + self._v_metaFiles[indexMeta]=(stats[stat.ST_MTIME],ret) # speicher im chache return ret @@ -161,13 +170,14 @@ class OSAS_storeOnline(SimpleItem): @return: metadata als html """ xmlInfos=self.findEntryInIndexMeta(path) - return OSAS_helpers.getMetaInfoFromXML(path,xmlInfos) - + if xmlInfos: + return OSAS_helpers.getMetaInfoFromXML(path,xmlInfos) + else: + return "" def readObjectsFromPath(self,path=""): """Liest files aus dem path und speichert im cache _v_filesystem. - - to do: files aus metadaten @param path : path relativ zum root folder des Storagesystems @return: directory der Form [pfad zum Objekt] -> (fileType,metadatum als String) @@ -186,10 +196,10 @@ class OSAS_storeOnline(SimpleItem): stats=os.stat(realPath) - # teste ob schon im cache - #if self._v_fileSystem.has_key(realPath) and (self._v_fileSystem[realPath][0]==stats[stat.ST_MTIME]): + #teste ob schon im cache + if self._v_fileSystem.has_key(realPath) and (self._v_fileSystem[realPath][0]==stats[stat.ST_MTIME]): - # return self._v_fileSystem[realPath][1] + return self._v_fileSystem[realPath][1] dir=os.listdir(realPath) ret={} @@ -298,7 +308,10 @@ class OSAS_storeOnline(SimpleItem): def getMetaFile(self,path): """Lese Metafile ein""" - return OSAS_helpers.getMetaFile(self,path) + tmp=OSAS_helpers.getMetaFile(self,path) + #zLOG.LOG("EE",zLOG.INFO,type(tmp)) + + return tmp InitializeClass(OSAS_storeOnline)