version 1.1, 2004/11/29 09:48:07
|
version 1.2, 2004/12/23 08:30:56
|
Line 1
|
Line 1
|
""" OSAS_contains the basic classes for configuring the OSAS and basic objects for displaying data. All site specific adaptation should be made in OSAS_Root""" |
""" OSAS_contains the basic classes for configuring the OSAS and |
|
basic objects for displaying data. |
|
All site specific adaptation should be made in OSAS_Root |
|
""" |
|
|
from OSAS_helpers import * |
from OSAS_helpers import * |
import OSAS_helpers |
import OSAS_helpers |
Line 15 import xml.dom.minidom
|
Line 18 import xml.dom.minidom
|
from types import * |
from types import * |
import zLOG |
import zLOG |
import os.path |
import os.path |
|
import Globals |
from Globals import package_home |
from Globals import package_home |
|
from AccessControl import ClassSecurityInfo |
|
|
|
|
class OSAS_viewerObject(Folder): |
class OSAS_viewerObject(Folder): |
Line 25 class OSAS_viewerObject(Folder):
|
Line 30 class OSAS_viewerObject(Folder):
|
""" |
""" |
meta_type="OSAS_ViewerObject__neu" |
meta_type="OSAS_ViewerObject__neu" |
|
|
|
|
def __init__(self,id,title,prefix,objectTypes,ignorePath=""): |
def __init__(self,id,title,prefix,objectTypes,ignorePath=""): |
"""inititialisiere die Klasse |
"""inititialisiere die Klasse |
|
|
Line 77 def manage_addViewerObject(self,id,title
|
Line 83 def manage_addViewerObject(self,id,title
|
|
|
class OSAS_root(Folder,Implicit): |
class OSAS_root(Folder,Implicit): |
"""Implicit Folder of the Storage Systems""" |
"""Implicit Folder of the Storage Systems""" |
|
|
|
security=ClassSecurityInfo() |
|
|
def __init__(self,id,rootFolderName,uploadServletUrl=None): |
def __init__(self,id,rootFolderName,uploadServletUrl=None): |
"""initialize a new instance |
"""initialize a new instance |
|
|
Line 122 class OSAS_root(Folder,Implicit):
|
Line 131 class OSAS_root(Folder,Implicit):
|
return self.uploadServletUrl |
return self.uploadServletUrl |
|
|
|
|
def downloadExternalXML(self,index_meta_url,xml_url): |
def validateIndexMeta(self,data): |
"""lade lese ein xml file aus URL und schreibe es in den localen Filebaum |
"""TO BE DONE testet ob data ein gueltiges index.meta file ist, zur Zeit wird dom erzeugt ohne validierung. |
|
@param data: zu testendes XML file als string |
|
@return: zeiger auf dom falls ok, None andernfalls (z.Z: immmer dom falls parse possible) |
|
""" |
|
try: |
|
return xml.dom.minidom.parseString(xmlneu) |
|
except: |
|
return None |
|
|
|
security.declareProtected('View management screens','uploadExternalXMLString','uploadExternalXMLUrl','uploadExternalXML') |
|
|
|
def uploadExternalXMLString(self,index_meta_url,xml_string): |
|
"""lese ein xml file aus xml_url und schreibe es in den lokalen Filebaum |
|
|
@param index_meta_url: url eines index.meta files auf dem lokalen Server, es gilt rootFolderName + pfad teil der url = pfad auf dem Server. |
@param index_meta_url: url eines index.meta files auf dem lokalen Server, es gilt rootFolderName + pfad teil der url = pfad auf dem Server. |
@param xml_url: externe url file hier ersetzt obiges index.meta |
@param xml_string: string mit index_meta ersetzt obiges index.meta |
@return: 'error' als String bei Fehler 'ok' bei ok. |
@return: 'error' als String bei Fehler 'ok' bei ok. |
""" |
""" |
|
|
|
return self.uploadExternalXML(index_meta_url,xml_string) |
|
|
xmlneu=urllib.urlopen(xml_url).read() |
|
|
|
try: |
def uploadExternalXMLUrl(self,index_meta_url,xml_url): |
dom=xml.dom.minidom.parseString(xmlneu) |
"""lese ein xml file aus xml_url und schreibe es in den lokalen Filebaum |
except: |
|
|
@param index_meta_url: url eines index.meta files auf dem lokalen Server, es gilt rootFolderName + pfad teil der url = pfad auf dem Server. |
|
@param xml_url: externe url auf ein index_meta ersetzt obiges index.meta |
|
@return: 'error' als String bei Fehler 'ok' bei ok. |
|
""" |
|
|
|
return self.uploadExternalXML(index_meta_url,xml_url) |
|
|
|
|
|
def uploadExternalXML(self,index_meta_url,xml_url=None,xml_string=None): |
|
"""lese ein xml file aus xml_url und schreibe es in den lokalen Filebaum |
|
|
|
@param index_meta_url: url eines index.meta files auf dem lokalen Server, es gilt rootFolderName + pfad teil der url = pfad auf dem Server. |
|
@param xml_url: (optional, default=None) externe url auf ein index_meta ersetzt obiges index.meta |
|
@param xml_string: (optional, default=None) string mit index_meta ersetzt obiges index.meta |
|
@return: 'error' als String bei Fehler 'ok' bei ok. |
|
""" |
|
|
|
if xml_url: |
|
xmlneu=urllib.urlopen(xml_url).read() |
|
else: |
|
xmlneu=xml_string |
|
|
|
dom=self.validateIndexMeta(xmlneu) |
|
if not dom: |
zLOG.LOG('OSAS_Root (downloadExternalXML)',zLOG.ERROR,'cannot parse: %s', xml_url) |
zLOG.LOG('OSAS_Root (downloadExternalXML)',zLOG.ERROR,'cannot parse: %s', xml_url) |
return "error" |
return "error" |
|
|
Line 149 class OSAS_root(Folder,Implicit):
|
Line 193 class OSAS_root(Folder,Implicit):
|
fh.close() |
fh.close() |
return "ok" |
return "ok" |
|
|
|
security.declareProtected('View','getIndexMetaFile') |
|
|
|
|
|
def getIndexMetaFile(self,index_meta): |
|
"""gibt index metafile aus |
|
@param index_meta: index_meta ist eine URI entweder url des index_meta oder file mit file:// |
|
""" |
|
filearray=[] |
|
urlparsed=urlparse(index_meta)[1:] |
|
|
|
for x in urlparsed: |
|
|
|
if not (x==''): |
|
filearray.append(x) |
|
|
|
path=os.sep.join(filearray) |
|
|
|
realPath=os.path.normpath(os.path.join(self.rootFolderName,path)) |
|
|
|
if realPath.find(self.rootFolderName) <0: #versuch auf Pfad unterhalb des Rootfolder zuzugreifen |
|
return {} |
|
|
|
|
|
if not os.path.isfile(realPath): |
|
return None,"(ERROR) path %s does not exist."%path |
|
|
|
|
|
fh=file(realPath,'r') |
|
str=fh.read() |
|
fh.close() |
|
return str |
|
|
|
|
|
Globals.InitializeClass(OSAS_root) |
|
|
def manage_addOSAS_rootForm(self): |
def manage_addOSAS_rootForm(self): |
"""interface for adding the OSAS_root""" |
"""interface for adding the OSAS_root""" |