version 1.10, 2005/02/11 16:27:01
|
version 1.15, 2005/03/03 20:41:00
|
Line 9 from OFS.Folder import Folder
|
Line 9 from OFS.Folder import Folder
|
from OFS.SimpleItem import SimpleItem |
from OFS.SimpleItem import SimpleItem |
from Globals import InitializeClass,package_home |
from Globals import InitializeClass,package_home |
import zLOG |
import zLOG |
|
import base64 |
|
import bz2 |
import os |
import os |
import os.path |
import os.path |
import stat |
import stat |
Line 17 from types import *
|
Line 19 from types import *
|
import xmlrpclib |
import xmlrpclib |
from OSAS_helpers import * |
from OSAS_helpers import * |
|
|
|
def decodeRPC(string): |
|
return bz2.decompress(base64.decodestring(string)) |
|
|
|
|
class OSAS_storeOnline(SimpleItem): |
class OSAS_storeOnline(SimpleItem): |
"""Webfrontend für das Storagesystem |
"""Webfrontend für das Storagesystem |
Line 28 class OSAS_storeOnline(SimpleItem):
|
Line 33 class OSAS_storeOnline(SimpleItem):
|
|
|
_v_fileSystem={} #chache fuer filesystem |
_v_fileSystem={} #chache fuer filesystem |
_v_metaFiles={} #chache fuer indexMeta |
_v_metaFiles={} #chache fuer indexMeta |
|
|
|
def getParentType(self,path): |
|
"""getFileType des parentordners""" |
|
|
|
realPath=os.path.split(path)[0] |
|
|
|
objects=self.readObjectsFromPath(realPath) |
|
|
|
return objects[os.path.join(realPath,".")][0] |
|
|
def getMetaFile(self,path): |
def getMetaFile(self,path): |
"""get index.meta and translate it to HTML""" |
"""get index.meta and translate it to HTML""" |
"""Lies Metafile ein |
"""Lies Metafile ein |
Line 101 class OSAS_storeOnline(SimpleItem):
|
Line 116 class OSAS_storeOnline(SimpleItem):
|
@param path: Pfad auf das Object relativ zum rootFolderName |
@param path: Pfad auf das Object relativ zum rootFolderName |
@return: metadata als html |
@return: metadata als html |
""" |
""" |
|
print "search for ",path |
xmlInfos=self.findEntryInIndexMeta(path) |
xmlInfos=self.findEntryInIndexMeta(path) |
|
print "RRRRRRRRRRRR",xmlInfos |
if xmlInfos: |
if xmlInfos: |
return OSAS_helpers.getMetaInfoFromXML(path,xmlInfos) |
return OSAS_helpers.getMetaInfoFromXML(path,xmlInfos) |
else: |
else: |
Line 115 class OSAS_storeOnline(SimpleItem):
|
Line 132 class OSAS_storeOnline(SimpleItem):
|
|
|
server=xmlrpclib.Server(self.serverUrl) |
server=xmlrpclib.Server(self.serverUrl) |
indexMeta=server.findIndexMeta(path) # suche index.meta |
indexMeta=server.findIndexMeta(path) # suche index.meta |
|
print "found indexMeta",indexMeta |
if not indexMeta: |
if not indexMeta: |
return None |
return None |
|
|
Line 127 class OSAS_storeOnline(SimpleItem):
|
Line 144 class OSAS_storeOnline(SimpleItem):
|
dom=xml.dom.minidom.parseString(server.getFile(indexMeta)) |
dom=xml.dom.minidom.parseString(server.getFile(indexMeta)) |
except: |
except: |
zLOG.LOG("OSAS_browser (findEntryInIndexMeta)",zLOG.ERROR,"Cannot parse: %s"%indexMeta) |
zLOG.LOG("OSAS_browser (findEntryInIndexMeta)",zLOG.ERROR,"Cannot parse: %s"%indexMeta) |
#ist path ein directory? |
return None |
dirs=dom.getElementsByTagName('dir') |
|
for dir in dirs: |
path=path.replace(realPath,'') |
pathes=dir.getElementsByTagName('path') |
(searchPath,name)=os.path.split(path) |
if pathes: |
if (len(searchPath)>0) and (searchPath[0]=="/"): |
pathX=OSAS_helpers.getText(pathes[0].childNodes) |
if len(searchPath)<=1: |
else: |
searchPath="" |
pathX="" |
|
names=dir.getElementsByTagName('name') |
|
if names: |
|
name=OSAS_helpers.getText(names[0].childNodes) |
|
else: |
else: |
name="" |
searchPath=searchPath[1:] |
|
#ist path ein directory? |
|
xpath="/resource/dir[name='%s' and path='%s']"%(name,searchPath) |
|
|
checkpath=os.path.normpath(os.path.join(realPath,pathX,name)) |
dirs=xml.xpath.Evaluate(xpath,dom) |
if checkpath==path: |
|
|
|
return dir.toxml() |
if len(dirs)>0: |
|
return dirs[0].toxml |
|
|
#ist path ein file? |
#ist path ein file? |
files=dom.getElementsByTagName('file') |
xpath="/resource/file[name='%s' and path='%s']"%(name,searchPath) |
for dir in dirs: |
|
pathes=dir.getElementsByTagName('path') |
|
if pathes: |
|
pathX=OSAS_helpers.getText(pathes[0].childNodes) |
|
else: |
|
pathX="" |
|
names=dir.getElementsByTagName('name') |
|
if names: |
|
name=OSAS_helpers.getText(names[0].childNodes) |
|
else: |
|
name="" |
|
|
|
checkpath=os.path.normpath(os.path.join(realPath,pathX,name)) |
|
if checkpath==path: |
|
|
|
return dir.toxml() |
dirs=xml.xpath.Evaluate(xpath,dom) |
|
|
|
if len(dirs)>0: |
|
return dirs[0].toxml() |
|
|
return None |
return None |
|
|
Line 179 class OSAS_storeOnline(SimpleItem):
|
Line 182 class OSAS_storeOnline(SimpleItem):
|
ret={} |
ret={} |
server=xmlrpclib.Server(self.serverUrl) |
server=xmlrpclib.Server(self.serverUrl) |
indexMeta,stats=server.findIndexMetaWithStats(path)#findex index.meta zu path. |
indexMeta,stats=server.findIndexMetaWithStats(path)#findex index.meta zu path. |
|
print "checking",path,indexMeta |
if not indexMeta: |
if not indexMeta: |
return ret |
return ret |
|
|
Line 261 class OSAS_storeOnline(SimpleItem):
|
Line 264 class OSAS_storeOnline(SimpleItem):
|
|
|
|
|
|
|
|
|
|
|
|
|
def readObjectsFromPath(self,path="",metaDataId=None): |
def readObjectsFromPath(self,path="",metaDataId=None): |
"""Liest files aus dem path und speichert im cache _v_filesystem. |
"""Liest files aus dem path und speichert im cache _v_filesystem. |
|
|
Line 300 class OSAS_storeOnline(SimpleItem):
|
Line 300 class OSAS_storeOnline(SimpleItem):
|
return None |
return None |
|
|
#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] |
indexMetas=server.getAllIndexMetasOfSubDirs(realPath) |
|
dir=indexMetas.keys() |
|
|
dir=server.listdir(realPath) |
|
ret={} |
ret={} |
for filename in dir: |
for filename in dir: |
|
print "doing",filename,indexMetas |
object=os.path.join(realPath,filename) |
object=os.path.join(realPath,filename) |
fileType=OSAS_helpers.checkOSASFileType(object) |
fileType=indexMetas[filename][0] |
|
|
if fileType: |
if fileType: |
if metaData: |
if (fileType=='OSAS_dir') and indexMetas.has_key(".") and indexMetas["."][1]: |
|
print "TEEEEEEEEEE" |
|
if(OSAS_helpers.isImageFolder(object,decodeRPC(indexMetas["."][1]))): |
|
fileType='OSAS_imageFolder' |
|
elif(OSAS_helpers.isVideoFolder(object,decodeRPC(indexMetas["."][1]))): |
|
fileType='OSAS_videoFolder' |
|
if metaData and indexMetas[filename][1]: |
|
print "do",filename |
|
ret[object]=(fileType,metaData.getDisplayFieldsAsStr(decodeRPC(indexMetas[filename][1]))) |
|
else: |
|
metaDataStr=self.findEntryInIndexMeta(object) |
|
print "MMMMMDDDDD",metaDataStr |
|
if metaDataStr: |
|
display=metaData.getDisplayFieldsAsStr(metaDataStr) |
|
dom=xml.dom.minidom.parseString(metaDataStr) |
|
|
|
if len(xml.xpath.Evaluate("/file/meta/video-file",dom))>0: |
|
fileType='OSAS_videoFile' |
|
|
ret[object]=(fileType,metaData.getDisplayFieldsAsStr(object)) |
|
else: |
else: |
ret[object]=(fileType,'') |
display="" |
|
print object,fileType,display |
|
|
|
ret[object]=(fileType,display) |
|
|
self._v_fileSystem[realPath]=(stats[stat.ST_MTIME],ret) # speicher im chache |
self._v_fileSystem[realPath]=(stats[stat.ST_MTIME],ret) # speicher im chache |
|
|
Line 330 class OSAS_storeOnline(SimpleItem):
|
Line 352 class OSAS_storeOnline(SimpleItem):
|
ret=[] |
ret=[] |
|
|
for handler in self.ZopeFind(self.aq_parent,obj_metatypes=['OSAS_HandlerObject__neu'],search_sub=1): |
for handler in self.ZopeFind(self.aq_parent,obj_metatypes=['OSAS_HandlerObject__neu'],search_sub=1): |
|
|
if type in handler[1].objectTypes: |
if type in handler[1].objectTypes: |
try: |
try: |
path=path.replace(getattr(handler[1],'ignorePath',''),'') |
path=path.replace(getattr(handler[1],'ignorePath',''),'') |
Line 372 class OSAS_storeOnline(SimpleItem):
|
Line 395 class OSAS_storeOnline(SimpleItem):
|
objectSorted=objects.keys() |
objectSorted=objects.keys() |
objectSorted.sort(sortLow) |
objectSorted.sort(sortLow) |
for object in objectSorted: |
for object in objectSorted: |
|
|
handler=self.giveHandlers(object,objects[object][0]) |
handler=self.giveHandlers(object,objects[object][0]) |
|
print "format",objects[object][0] |
if objects[object][0]=="OSAS_dir": |
if objects[object][0]=="OSAS_dir": |
|
|
string="""<a href="?path=%s">%s</a>"""%(object,os.path.split(object)[1]) |
string="""<a href="?path=%s">%s</a>"""%(object,os.path.split(object)[1]) |