--- OSAS/OSA_system/OSAS_show.py 2003/09/25 17:52:02 1.2 +++ OSAS/OSA_system/OSAS_show.py 2004/04/05 21:54:42 1.17 @@ -1,22 +1,30 @@ -# Classes for displaying, browsing and organizing the archive +""" Classes for displaying, browsing and organizing the archive +20040303 Needs configuration for rescaling thumbs + +""" import addFolder from OFS.Folder import Folder from OFS.SimpleItem import SimpleItem from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplate import PageTemplate +from AccessControl import ClassSecurityInfo +from Globals import InitializeClass class OSAS_ShowOnline(SimpleItem): + security=ClassSecurityInfo() + """OnlineBrowser""" def __init__(self,id): """initialize a new instance""" self.id = id meta_type="OSAS_ShowOnline" - + + security.declareProtected('View','index_html') def index_html(self): """main view""" - pt=PageTemplateFile('products/OSA_system/OSAS_ViewFiles.zpt').__of__(self) + pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_ViewFiles.zpt').__of__(self) return pt() def getfilesystem2(self,start,reload=0): @@ -51,10 +59,12 @@ class OSAS_ShowOnline(SimpleItem): """Oeffnen bzw. schließen der Subfolders""" self.tree(path).toggle(path,file) return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+"?path="+path) - + +InitializeClass(OSAS_ShowOnline) + def manage_AddOSAS_ShowOnlineForm(self): """interface for adding the OSAS_root""" - pt=PageTemplateFile('products/OSA_system/AddOSAS_ShowOnline.zpt').__of__(self) + pt=PageTemplateFile('Products/OSA_system/zpt/AddOSAS_ShowOnline.zpt').__of__(self) return pt() def manage_AddOSAS_ShowOnline(self,id,RESPONSE=None): @@ -67,17 +77,41 @@ def manage_AddOSAS_ShowOnline(self,id,RE class OSAS_StoreOnline(SimpleItem): """Webfrontend für das Storagesystem""" + security=ClassSecurityInfo() + def __init__(self,id): """initialize a new instance""" self.id = id meta_type="OSAS_StoreOnline" + security.declareProtected('View','index_html') def index_html(self): """main view""" - pt=PageTemplateFile('products/OSA_system/OSAS_StoreFiles.zpt').__of__(self) + pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_StoreFiles.zpt').__of__(self) + return pt() + + def readContexts(self,path): + """Zeige Contexte""" + if os.path.exists(path+"/index.meta"): + + return readContexts(path) + + else: + + return [] + + def rescaleThumbs(self,path): + """rescale thumbs of images in path""" + + os.popen("ssh nausikaa2.rz-berlin.mpg.de /usr/local/mpiwg/scripts/scaleomat.pl %s /mpiwg/temp/online/scaled/thumb 90 --replace >> /tmp/sc.out &"% re.sub('/mpiwg/online/','',self.REQUEST['path'])) + + self.REQUEST.SESSION['path']=self.REQUEST['path'] + #return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']) + pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_scaled.zpt').__of__(self) return pt() + def getfilesystem2(self,start,reload=0): """load filesystem""" @@ -116,21 +150,26 @@ class OSAS_StoreOnline(SimpleItem): return isFolder(self,path) def isScannedDocument(self,path): - """Test ob Eintrag ein Folder ist""" + """Test ob Eintrag ein Scanned Document ist""" return isScannedDocument(self,path) def isFullText(self,path,folder_name): """Test ob Eintrag ein Folder ist""" return isFullText(path,folder_name) - def addFolderForm(self,path): - """add a new path""" - pt=PageTemplateFile('products/OSA_system/OSAS_addFolder.zpt').__of__(self) - return pt() + def isPresentation(self,path,folder_name): + """Test ob Eintrag ein Folder ist""" + return isPresentation(path,folder_name) def date(self): return strftime("%d.%m.%Y",localtime()) + def addFolderForm(self,path): + """add a new path""" + pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_addFolder.zpt').__of__(self) + return pt() + + def addFolder(self,path,folder_name,description,archive_creation_date,creator): """add the folder to the filesystem and write the metadata files""" return addFolder.addFolder(self,path,folder_name,description,archive_creation_date,creator) @@ -142,9 +181,10 @@ class OSAS_StoreOnline(SimpleItem): indexmeta=dom.toxml() except: indexmeta="" + self.REQUEST.SESSION['indexmeta']=indexmeta self.REQUEST.SESSION['path']=path - newtemplate=PageTemplateFile('products/OSA_system/editindex').__of__(self) + newtemplate=PageTemplateFile('Products/OSA_system/zpt/editindex').__of__(self) return newtemplate() def EditIndex2(self): @@ -152,7 +192,7 @@ class OSAS_StoreOnline(SimpleItem): if not self.REQUEST.has_key('fileupload'): #newtext=urllib.unquote(self.REQUEST['indexmeta']) newtext=self.REQUEST['indexmeta'] - print newtext + else: self.file_name=self.REQUEST['fileupload'].filename #newtext=self.REQUEST.form['fileupload'].read() @@ -163,12 +203,16 @@ class OSAS_StoreOnline(SimpleItem): indexmeta.writelines(newtext) return self.REQUEST.response.redirect(self.REQUEST['URL1']+"?path="+self.REQUEST.SESSION['path']) - + def add_metafile(self): + """nothing""" + pt=PageTemplateFile('Products/OSA_system/zpt/OSAS_addmetadata.zpt').__of__(self) + return pt() +InitializeClass(OSAS_StoreOnline) def manage_AddOSAS_StoreOnlineForm(self): """interface for adding the OSAS_root""" - pt=PageTemplateFile('products/OSA_system/AddOSAS_StoreOnline.zpt').__of__(self) + pt=PageTemplateFile('Products/OSA_system/zpt/AddOSAS_StoreOnline.zpt').__of__(self) return pt() def manage_AddOSAS_StoreOnline(self,id,RESPONSE=None): @@ -181,6 +225,23 @@ def manage_AddOSAS_StoreOnline(self,id,R +def readContexts(path): + """ReadContext from index.meta""" + dom=xml.dom.minidom.parse(path+"/index.meta") + nodes=dom.getElementsByTagName('context') + ret=[] + + + for node in nodes: + try: + link=getText(node.getElementsByTagName('link')[0].childNodes) + name=getText(node.getElementsByTagName('name')[0].childNodes) + ret.append((link,name)) + except: + """nothing""" + return ret + + ### Ab hier Baustelle @@ -193,7 +254,11 @@ from AccessControl import ClassSecurityI from AccessControl.Role import RoleManager from Acquisition import Implicit from Globals import Persistent -from time import strptime +try: + from time import strptime +except: + print "ignoring time.strptime import" + from time import strftime import time import os.path @@ -324,27 +389,29 @@ class filesystem(Implicit, Persistent, R def archive_the_path(self,path): """parse indexmeta and return digilib path""" + try: #f = os.popen("cat "+path+"/index.meta","r") f =file(path+"/index.meta","r") lines = f.read() - + try: dom = xml.dom.minidom.parseString(lines) - if getText(dom.getElementsByTagName("content-type")[0].childNodes)=="folder": - """folder nicht archivieren""" - return 0 + if dom.getElementsByTagName("content-type"): + if getText(dom.getElementsByTagName("content-type")[0].childNodes)=="folder": + """folder nicht archivieren""" + return 0 + + archive_storage_date=getText(dom.getElementsByTagName("archive-storage-date")[0].childNodes) + + if archive_storage_date=="": + + """leer also archivieren""" + return 1 else: - archive_storage_date=getText(dom.getElementsByTagName("archive-storage-date")[0].childNodes) - - if archive_storage_date=="": - - """leer also archivieren""" - return 1 - else: - """nicht archivieren""" - return 0 + """nicht archivieren""" + return 0 except: """kein tag also archivieren""" return 1 @@ -424,6 +491,7 @@ class filesystem2(Implicit, Persistent, def getfs(self,start): """load filessystem""" + f = os.popen("find "+ start+" -name '*' ","r") lines = f.readlines() @@ -559,6 +627,8 @@ class browse(Implicit, Persistent, RoleM def getfs(start): """return filesystem""" + + f = os.popen("find "+ start+" -name '*'","r") lines = f.readlines() return lines @@ -819,7 +889,7 @@ def getText(nodelist): def getBib(nodelist): rc= "" - print "HI" + for node in nodelist: if node.nodeType == node.ELEMENT_NODE: @@ -829,7 +899,7 @@ def getBib(nodelist): return rc+"
" def getMetafile(path): - """get index.meta""" + """get index.meta and translate it to an HTML""" html=[] if not os.path.exists(path+"/index.meta"): @@ -838,10 +908,25 @@ def getMetafile(path): f = os.popen("cat "+path+"/index.meta","r") lines = f.read() dom = xml.dom.minidom.parseString(lines) - name=getText(dom.getElementsByTagName("name")[0].childNodes) - creator=getText(dom.getElementsByTagName("creator")[0].childNodes) - creation_date=getText(dom.getElementsByTagName("archive-creation-date")[0].childNodes) - description=getText(dom.getElementsByTagName("description")[0].childNodes) + try: + name=getText(dom.getElementsByTagName("name")[0].childNodes) + except: + name="NOT_DEFINED!!!" + try: + creator=getText(dom.getElementsByTagName("creator")[0].childNodes) + except: + creator="NOT_DEFINED!!!" + + try: + creation_date=getText(dom.getElementsByTagName("archive-creation-date")[0].childNodes) + except: + creation_date="NOT_DEFINED!!!" + + try: + description=getText(dom.getElementsByTagName("description")[0].childNodes) + except: + description="NOT_DEFINED!!!" + try: type=getText(dom.getElementsByTagName("content-type")[0].childNodes) except: @@ -862,7 +947,7 @@ def getMetafile(path): else: html=html+"

Info

" html=html+getBib(bib.childNodes) - print html + except: """none""" @@ -875,6 +960,8 @@ def hasMetafile(path): return os.path.exists(path+"/index.meta") #return path + + def isdigilib2(path): """check if folder is candidate for digilib without metadata""" try: