--- ECHO_content/ECHO_collection.py 2004/07/16 17:49:44 1.139 +++ ECHO_content/ECHO_collection.py 2004/07/18 14:58:32 1.144 @@ -29,7 +29,7 @@ from Products.PageTemplates.ZopePageTemp from Globals import Persistent, package_home from Acquisition import Implicit from ECHO_helpers import displayTypes - +import urllib try: from psycopg import libpq @@ -46,7 +46,34 @@ import xml.dom.minidom from ECHO_graphicalOverview import javaHandler,javaScriptMain import ECHO_helpers -def getCopyrightsFromForm(self,argv): +def getRDFDescription(self,linkURL,urn=None): + """rdf""" + ret="" + about="""""" + name="""%s""" + link="""%s""" + #link="""""" + type="""%s""" + + if not urn: + urn="urn:"+re.sub('/',':',self.absolute_url()) + + about2=about%urn + + if hasattr(self,'label') and not (self.label==""): + name2=name%urllib.quote(self.label) + elif not self.title=="": + name2=name%urllib.quote(self.title) + else: + name2=name%self.getId() + + link2=link%urllib.quote(linkURL) + type2=type%self.meta_type + + ret=about2+"\n"+name2+"\n"+link2+"\n"+type2+"\n" + return ret + +def getCopyrightsFromForm(self,argv): medias={} partners={} copyrights={} @@ -477,6 +504,8 @@ def manage_addECHO_layoutTemplate(self, REQUEST.RESPONSE.redirect(u+'/manage_main') return '' + + class ECHO_resource(Folder,Persistent): """ECHO Ressource""" security=ClassSecurityInfo() @@ -487,20 +516,9 @@ class ECHO_resource(Folder,Persistent): getSubCols = ECHO_helpers.getSubCols security.declareProtected('View','index_html') - def getRDF(self): + def getRDF(self,urn=None): """rdf""" - ret="" - about="""""" - name="""%s""" - link="""%s""" - urn="urn:"+re.sub('/',':',self.absolute_url()) - - about2=about%urn - name2=name%self.getId() - link2=link%self.link - - ret=about2+"\n"+name2+"\n"+link2+"\n"+"" - return ret + return getRDFDescription(self,self.link,urn=urn) def getAccessRightSelectorHTML(self,outlook="select"): @@ -1489,32 +1507,35 @@ class ECHO_collection(Folder, Persistent path="/mpiwg/online/permanent/shipbuilding" - def getRDF(self): + def showRDF(self): + """showrdf""" + self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') + ret="""\n\n""" + ret+=self.getRDF(urn="urn:echo:collectionroot")+"\n" + ret+="""""" + return ret + + def getRDF(self,urn=None): """rdf of the collection""" - contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) - about="""""" - name="""%s""" - - urn="urn:"+re.sub('/',':',self.absolute_url()) + contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) - about2=about%urn - name2=name%self.getId() - + ret=getRDFDescription(self,self.absolute_url(),urn=urn) - ret=about2+"\n"+name2+"\n"+"" - urn="urn:"+re.sub('/',':',self.absolute_url()) + if not urn: + urn="urn:"+re.sub('/',':',self.absolute_url()) + li="""\n""" for content in contents: ret+=content[1].getRDF()+"\n" - ret+="""\n"""%urn + ret+="""\n"""%urn for content in contents: nurn="urn:"+re.sub('/',':',content[1].absolute_url()) ret+=li%nurn - return ret+"" + return ret+"" def changeLabels(self): @@ -2220,22 +2241,26 @@ class ECHO_group(ECHO_collection): security.declareProtected('View','index_html') - def getRDF(self): + def getRDF(self,urn=None): """rdf of the collection""" contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) + + ret=getRDFDescription(self,self.absolute_url(),urn) + + urn="urn:"+re.sub('/',':',self.absolute_url()) li="""\n""" - ret="" + for content in contents: ret+=content[1].getRDF()+"\n" - ret+="""\n"""%urn + ret+="""\n"""%urn for content in contents: nurn="urn:"+re.sub('/',':',content[1].absolute_url()) ret+=li%nurn - return ret+"" + return ret+"" def index_html(self): """standard page""" @@ -2452,6 +2477,35 @@ class ECHO_root(Folder,Persistent,Implic security=ClassSecurityInfo() meta_type="ECHO_root" + + def showRDF(self): + """showrdf""" + self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') + ret="""\n""" + ret+=self.getRDF(urn="echo:collectionroot")+"\n" + + ret+="""""" + return ret + + def getRDF(self,urn=None): + """rdf of the collection""" + + contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) + + ret=getRDFDescription(self,self.absolute_url(),urn=urn) + + li="""\n""" + + + for content in contents: + ret+=content[1].getRDF()+"\n" + + ret+="""\n"""%urn + for content in contents: + nurn="urn:"+re.sub('/',':',content[1].absolute_url()) + ret+=li%nurn + return ret+"" + def showContent(self,path): """return content/html"""