version 1.2, 2004/12/23 08:30:55
|
version 1.5, 2004/12/23 15:56:19
|
Line 13 import os
|
Line 13 import os
|
import os.path |
import os.path |
import stat |
import stat |
import xml.dom.minidom |
import xml.dom.minidom |
|
from types import * |
|
|
class OSAS_storeOnline(SimpleItem): |
class OSAS_storeOnline(SimpleItem): |
"""Webfrontend für das Storagesystem |
"""Webfrontend für das Storagesystem |
Line 23 class OSAS_storeOnline(SimpleItem):
|
Line 24 class OSAS_storeOnline(SimpleItem):
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
|
|
_v_fileSystem={} #chache fuer filesystem |
_v_fileSystem={} #chache fuer filesystem |
|
_v_metaFiles={} #chache fuer indexMeta |
|
|
def __init__(self,id): |
def __init__(self,id): |
"""initialize a new instance""" |
"""initialize a new instance""" |
Line 57 class OSAS_storeOnline(SimpleItem):
|
Line 59 class OSAS_storeOnline(SimpleItem):
|
def findEntryInIndexMeta(self,path): |
def findEntryInIndexMeta(self,path): |
"""fragm xml zum path |
"""fragm xml zum path |
@param path: Pfad auf das Object relativ zum rootFolderName |
@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) |
indexMeta=self.findIndexMeta(path) |
|
if not indexMeta: |
|
return None |
realPath=os.path.split(indexMeta)[0] |
realPath=os.path.split(indexMeta)[0] |
path=os.path.normpath(os.path.join(self.rootFolderName,path)) |
path=os.path.normpath(os.path.join(self.rootFolderName,path)) |
|
|
Line 123 class OSAS_storeOnline(SimpleItem):
|
Line 126 class OSAS_storeOnline(SimpleItem):
|
if path and (path[0]==os.sep): |
if path and (path[0]==os.sep): |
path=path[1:] |
path=path[1:] |
|
|
|
stats=os.stat(indexMeta) |
|
|
|
#teste ob schon im cache |
|
if self._v_metaFiles.has_key(path) and (self._v_metaFiles[path][0]==stats[stat.ST_MTIME]): |
|
#print "cache",path |
|
return self._v_metaFiles[path][1] |
|
|
dom=xml.dom.minidom.parse(indexMeta) |
dom=xml.dom.minidom.parse(indexMeta) |
|
|
Line 141 class OSAS_storeOnline(SimpleItem):
|
Line 150 class OSAS_storeOnline(SimpleItem):
|
else: |
else: |
name="" |
name="" |
|
|
|
#print "PP",pathX,path |
if pathX==path: |
if pathX==path: |
if dir.tagName=="dir": |
if dir.tagName=="dir": |
fileType="OSAS_dir_archive" |
fileType="OSAS_dir_archive" |
Line 151 class OSAS_storeOnline(SimpleItem):
|
Line 160 class OSAS_storeOnline(SimpleItem):
|
object=os.path.join(realPath,pathX,name) |
object=os.path.join(realPath,pathX,name) |
ret[object]=(fileType,'') |
ret[object]=(fileType,'') |
|
|
|
self._v_metaFiles[path]=(stats[stat.ST_MTIME],ret) # speicher im chache |
return ret |
return ret |
|
|
|
|
Line 161 class OSAS_storeOnline(SimpleItem):
|
Line 170 class OSAS_storeOnline(SimpleItem):
|
@return: metadata als html |
@return: metadata als html |
""" |
""" |
xmlInfos=self.findEntryInIndexMeta(path) |
xmlInfos=self.findEntryInIndexMeta(path) |
|
if xmlInfos: |
return OSAS_helpers.getMetaInfoFromXML(path,xmlInfos) |
return OSAS_helpers.getMetaInfoFromXML(path,xmlInfos) |
|
else: |
|
return "" |
|
|
|
|
def readObjectsFromPath(self,path=""): |
def readObjectsFromPath(self,path=""): |
"""Liest files aus dem path und speichert im cache _v_filesystem. |
"""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 |
@param path : path relativ zum root folder des Storagesystems |
@return: directory der Form [pfad zum Objekt] -> (fileType,metadatum als String) |
@return: directory der Form [pfad zum Objekt] -> (fileType,metadatum als String) |
Line 187 class OSAS_storeOnline(SimpleItem):
|
Line 197 class OSAS_storeOnline(SimpleItem):
|
stats=os.stat(realPath) |
stats=os.stat(realPath) |
|
|
# teste ob schon im cache |
# teste ob schon im cache |
#if self._v_fileSystem.has_key(realPath) and (self._v_fileSystem[realPath][0]==stats[stat.ST_MTIME]): |
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) |
dir=os.listdir(realPath) |
ret={} |
ret={} |
Line 206 class OSAS_storeOnline(SimpleItem):
|
Line 216 class OSAS_storeOnline(SimpleItem):
|
return ret |
return ret |
|
|
def giveHandlers(self,path,type): |
def giveHandlers(self,path,type): |
"""teste ob fuer diesen Typ, viewer definiert sind und gibt einen entsprechenden Link zurueck, der das Object mit diesem Handler ausfuehrt. |
"""teste ob fuer diesen Typ, handler definiert sind und gibt einen entsprechenden Link zurueck, der das Object mit diesem Handler ausfuehrt. |
@param path: Pfad auf das Objekt |
@param path: Pfad auf das Objekt |
@param type: Typ des Objektes |
@param type: Typ des Objektes |
@return: (string) html-Fragment, link der das Objekt mit diesem Handler anzeigt. |
@return: (string) html-Fragment, link der das Objekt mit diesem Handler anzeigt. |
""" |
""" |
ret=[] |
ret=[] |
|
|
for viewer in self.ZopeFind(self.aq_parent,obj_metatypes=['OSAS_ViewerObject__neu'],search_sub=1): |
for handler in self.ZopeFind(self.aq_parent,obj_metatypes=['OSAS_HandlerObject__neu'],search_sub=1): |
if type in viewer[1].objectTypes: |
if type in handler[1].objectTypes: |
path=path.replace(getattr(viewer[1],'ignorePath',''),'') |
path=path.replace(getattr(handler[1],'ignorePath',''),'') |
url=viewer[1].prefix%path |
url=handler[1].prefix%path |
text=viewer[1].title |
text=handler[1].title |
string="""<a target="_blank" href="%s">%s</a>"""%(url,text) |
string="""<a target="_blank" href="%s">%s</a>"""%(url,text) |
ret.append(string) |
ret.append(string) |
return ret |
return ret |
Line 298 class OSAS_storeOnline(SimpleItem):
|
Line 308 class OSAS_storeOnline(SimpleItem):
|
|
|
def getMetaFile(self,path): |
def getMetaFile(self,path): |
"""Lese Metafile ein""" |
"""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) |
InitializeClass(OSAS_storeOnline) |
|
|