version 1.21, 2004/04/02 07:57:25
|
version 1.24, 2004/04/05 21:54:42
|
Line 4
|
Line 4
|
from OSAS_helpers import readArchimedesXML, getISO, getText |
from OSAS_helpers import readArchimedesXML, getISO, getText |
import os |
import os |
import xml.dom.minidom |
import xml.dom.minidom |
|
import re |
import urllib |
import urllib |
import OSAS_add |
import OSAS_add |
import OSAS_show |
import OSAS_show |
Line 62 class OSAS_add_Document(Folder):
|
Line 62 class OSAS_add_Document(Folder):
|
security.declarePublic('index_html') |
security.declarePublic('index_html') |
def index_html(self): |
def index_html(self): |
"""stantard aufruf""" |
"""stantard aufruf""" |
return OSAS_add.add(self,no_upload=1) |
return OSAS_add.add(self.standardMD,no_upload=1) |
|
|
|
|
security.declarePublic('add2') |
security.declarePublic('add2') |
def add2(self): |
def add2(self): |
""" anlegen naechster schritt""" |
""" anlegen naechster schritt""" |
return OSAS_add.add2(self) |
return OSAS_add.add2(self.standardMD) |
|
|
def add3(self): |
def add3(self): |
"""Foldername""" |
"""Foldername""" |
Line 184 class OSAS_add_contextData(Folder):
|
Line 184 class OSAS_add_contextData(Folder):
|
def startElement(self,name,attrs): |
def startElement(self,name,attrs): |
if name=="element": |
if name=="element": |
self.depth+=1 |
self.depth+=1 |
self.retStr+=spaces(self.depth)+"<input type='checkbox' name='collection' value='%s'>%s</input>"%(attrs.get('url'),attrs.get('name'))+"<br>\n" |
begin="" |
|
end="" |
|
if self.depth==1: |
|
print "hi" |
|
begin="<b>" |
|
end="</b>" |
|
|
|
self.retStr+=spaces(self.depth)+"<input type='radio' name='collection' value='%s'>%s</input>"%(attrs.get('url'),begin+attrs.get('name')+end)+"<br>\n" |
|
|
|
|
|
|
Line 193 class OSAS_add_contextData(Folder):
|
Line 200 class OSAS_add_contextData(Folder):
|
self.depth-=1 |
self.depth-=1 |
|
|
|
|
|
try: |
|
URL+="/getCollectionTreeXML" |
parser=make_parser() |
parser=make_parser() |
curHandler=requestHandler() |
curHandler=requestHandler() |
parser.setContentHandler(curHandler) |
parser.setContentHandler(curHandler) |
#return urllib.urlopen(URL).read() |
|
parser.parse(urllib.urlopen(URL)) |
parser.parse(urllib.urlopen(URL)) |
return curHandler.retStr |
return curHandler.retStr |
|
except: |
|
return urllib.urlopen(URL).read() |
|
|
def __init__(self,id,collection): |
def __init__(self,id,collection): |
self.id=id |
self.id=id |
self.collection=collection |
self.collection=collection |
|
|
def getChilds(self,id,depth,items): |
|
list=[] |
|
for object in items: |
|
if (depth==object[2])&(id==object[0]): |
|
list.append(object) |
|
return list |
|
|
|
|
|
|
|
def printChilds(self,startItem,depth,items,enddepth): |
|
"""NOT USED ANYMORE""" |
|
def spaces(depth): |
|
tmp="" |
|
k=0 |
|
while k<2*depth: |
|
k+=1 |
|
tmp=tmp+" "+" " |
|
return tmp |
|
|
|
def retLink(object): |
|
return "<input type='checkbox' name='collection' value='%s'>%s</input>"% (string.join(object.getPhysicalPath(),"."),object.title) |
|
|
|
depth+=1 |
|
childs=self.getChilds(startItem,depth,items) |
|
tmp="" |
|
for child in childs: |
|
if depth < enddepth: |
|
tmp=tmp+spaces(depth) |
|
|
|
tmp= tmp+retLink(child[1])+"<br>"+self.printChilds(child[1],depth,items,enddepth) |
def getPartners(self,URL): |
else: |
"""Zeige Partnerliste""" |
tmp=tmp+spaces(2*depth) |
class requestHandler(ContentHandler): |
tmp = tmp+retLink(child[1]) |
def __init__(self): |
|
self.ret=[] |
|
|
return tmp |
def startElement(self,name,attrs): |
|
if name=="partner": |
|
self.ret.append((attrs.get('id'),attrs.get('title'))) |
|
|
|
|
def generateTree(self,depth=10): |
URL+="/getPartnersXML" |
"""Erzeugt HTML-Tree der Collection NOTE USED ANYMORE""" |
|
|
|
exec("items=self.getPhysicalRoot()."+self.collection+".getCollectionTree()") |
try: |
#print items[0][0] |
|
|
|
childs=self.printChilds(items[0][0],0,items,depth) |
parser=make_parser() |
|
curHandler=requestHandler() |
|
parser.setContentHandler(curHandler) |
|
|
return childs |
parser.parse(urllib.urlopen(URL)) |
|
return curHandler.ret |
|
except: |
|
return [("",urllib.urlopen(URL).read())] |
|
|
def getPartners(self): |
|
"""Zeige Partnerliste""" |
|
exec("items=self.getPhysicalRoot()."+self.collection+".partners.getPartners()") |
|
return items |
|
|
|
def addContextData(self,path): |
def addContextData(self,path): |
"""Hinzufügen zu einer Sammlung""" |
"""Hinzufügen zu einer Sammlung""" |
Line 495 class OSAS_combineTextImage(Folder):
|
Line 482 class OSAS_combineTextImage(Folder):
|
OSAS_add.combineTextImage2(self,path) # Add images |
OSAS_add.combineTextImage2(self,path) # Add images |
splitted=path.split("/") |
splitted=path.split("/") |
linkPath=splitted[len(splitted)-1] |
linkPath=splitted[len(splitted)-1] |
linkViewerEnvironment="http://nausikaa2.mpiwg-berlin.mpg.de:86/cgi-bin/toc/toc.x.cgi?dir=%s&step=thumb" % linkPath |
linkViewerEnvironment="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir=%s&step=thumb" % linkPath |
self.REQUEST.SESSION['linkViewerEnvironment']=linkViewerEnvironment |
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) |
pt=PageTemplateFile('Products/OSA_system/zpt/AddOSAS_combineTextImageFinal.zpt').__of__(self) |
|
|
Line 512 class OSAS_combineTextImage(Folder):
|
Line 499 class OSAS_combineTextImage(Folder):
|
else: |
else: |
return None |
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""" |
"""Created an additional entry to the index.meta file of path""" |
dom=xml.dom.minidom.parse(path+"/index.meta") |
dom=xml.dom.minidom.parse(path+"/index.meta") |
node=dom.getElementsByTagName('resource')[0] |
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') |
subnode=dom.createElement('context') |
|
|
linknode=dom.createElement('link') |
linknode=dom.createElement('link') |