--- OSAS/OSA_system/OSAS_addfiles.py 2004/04/02 17:38:40 1.23
+++ OSAS/OSA_system/OSAS_addfiles.py 2004/04/05 21:54:42 1.24
@@ -4,7 +4,7 @@
from OSAS_helpers import readArchimedesXML, getISO, getText
import os
import xml.dom.minidom
-
+import re
import urllib
import OSAS_add
import OSAS_show
@@ -62,13 +62,13 @@ class OSAS_add_Document(Folder):
security.declarePublic('index_html')
def index_html(self):
"""stantard aufruf"""
- return OSAS_add.add(self,no_upload=1)
+ return OSAS_add.add(self.standardMD,no_upload=1)
security.declarePublic('add2')
def add2(self):
""" anlegen naechster schritt"""
- return OSAS_add.add2(self)
+ return OSAS_add.add2(self.standardMD)
def add3(self):
"""Foldername"""
@@ -184,7 +184,14 @@ class OSAS_add_contextData(Folder):
def startElement(self,name,attrs):
if name=="element":
self.depth+=1
- self.retStr+=spaces(self.depth)+"%s"%(attrs.get('url'),attrs.get('name'))+"
\n"
+ begin=""
+ end=""
+ if self.depth==1:
+ print "hi"
+ begin=""
+ end=""
+
+ self.retStr+=spaces(self.depth)+"%s"%(attrs.get('url'),begin+attrs.get('name')+end)+"
\n"
@@ -478,7 +485,7 @@ class OSAS_combineTextImage(Folder):
linkViewerEnvironment="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir=%s&step=thumb" % linkPath
self.REQUEST.SESSION['linkViewerEnvironment']=linkViewerEnvironment
- writeToContext(path,linkViewerEnvironment,"ECHO standard environment")
+ writeToContext(path,linkViewerEnvironment,"ECHO standard environment",unique="yes")
pt=PageTemplateFile('Products/OSA_system/zpt/AddOSAS_combineTextImageFinal.zpt').__of__(self)
@@ -492,11 +499,23 @@ class OSAS_combineTextImage(Folder):
else:
return None
-def writeToContext(path,link,description):
+def writeToContext(path,link,description,unique="no"):
"""Created an additional entry to the index.meta file of path"""
dom=xml.dom.minidom.parse(path+"/index.meta")
node=dom.getElementsByTagName('resource')[0]
+ if unique=="yes":
+
+ contexts=node.getElementsByTagName('context')
+ for context in contexts:
+ nameTag=getText(context.getElementsByTagName('name')[0].childNodes)
+ linkTag=getText(context.getElementsByTagName('link')[0].childNodes)
+
+ print "unique",context,nameTag,description,linkTag,link
+ linkTag=re.sub("\:86","",linkTag) # alter port 86 gleich ohne port nummer (hack)
+ if (nameTag==description) and (linkTag==link):
+ node.removeChild(context).unlink()
+
subnode=dom.createElement('context')
linknode=dom.createElement('link')