--- ECHO_content/ECHO_collection.py 2008/12/17 12:12:26 1.301 +++ ECHO_content/ECHO_collection.py 2010/10/11 13:15:00 1.309 @@ -1,4 +1,4 @@ -"""New version of the product started February, 8th. Without scientific classification, use content-type for further classification.""" +"""New version of the produc started February, 8th. Without scientific classification, use content-type for further classification.""" """Echo collection provides the classes for the ECHO content web-site. class ECHO_collection is the basis class for an ECHO collection. @@ -106,6 +106,7 @@ def setECHO_collectionInformation(self,t self.weight=weight import ECHO_resource +from ECHO_resource import manage_addECHO_resource class ECHO_resource(ECHO_resource.ECHO_resource): """depricated use class in ECHO_resource.py""" @@ -379,7 +380,7 @@ class ECHO_fullText(ZopePageTemplate,ECH try: dom=xml.dom.minidom.parseString(self()) except: - dom=xml.dom.minidom.parseString(self().encode('latin-1')) + dom=xml.dom.minidom.parseString(self.utf8ify(self())) pages=dom.getElementsByTagName('page') return pages[int(nr)-1].toxml() @@ -721,7 +722,7 @@ class ECHO_collection(CatalogAware, Fold ret=None for name in zf.namelist(): - fn=tempfile.mkstemp()[1] + ds,fn=tempfile.mkstemp() tf=file(fn,"w") x=zf.read(name) tf.write(x) @@ -732,8 +733,11 @@ class ECHO_collection(CatalogAware, Fold if not ret: ret="" ret+="Cannot import: %s (Already existing?)
"%name + os.close(ds) os.remove(fn) - + + zf.close() + if ret: return """%s"""%ret if RESPONSE: @@ -852,17 +856,24 @@ class ECHO_collection(CatalogAware, Fold if not urn: urn=self.absolute_url() - li="""\n""" + li="""\n""" for content in contents: + try: ret+=content[1].getRDF()+"\n" - - ret+="""\n"""%urn + except: + logging.error("getrdf: "+repr(content[1].getRDF())) + try: + ret+=self.unicodify(content[1].getRDF())+"\n" + except: + logging.error("--still cannot do it") + ret+=repr(content[1].getRDF())+"\n" + ret+="""\n"""%urn for content in contents: nurn=content[1].absolute_url() ret+=li%nurn - return ret+"" + return ret+"" @@ -992,7 +1003,7 @@ class ECHO_collection(CatalogAware, Fold pass return ret - def importCollection(self,path=None,RESPONSE=None): + def importCollection(self,path=None,viewerUrl=None,metaDataUrl=None,replacePathPermanent=None,replacePathExperimental=None,RESPONSE=None): """liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" if path is None: @@ -1005,15 +1016,20 @@ class ECHO_collection(CatalogAware, Fold if fileName: - tempPath=re.sub("/mpiwg/online","",path) - link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg" + if (replacePathExperimental and replacePathExperimental!=''): + path=re.sub(replacePathExperimental,"/mpiwg/online/experimental",path) + + if (replacePathPermanent and replacePathPermanent!=''): + path=re.sub(replacePathPermanent,"/mpiwg/online/permanent",path) + + link=viewerUrl%(path+"/"+fileName+"/pageimg") - metalink=self.path+"/"+fileName+"/index.meta" + metalink=metaDataUrl+"/"+path+"/"+fileName+"/index.meta" try: #link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb" - newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'generated','book','','','','','','') + newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'','book','','','','','','') self._setObject(fileName,newObj) genObj=getattr(self,fileName) @@ -1610,17 +1626,17 @@ class ECHO_group(ECHO_collection): if not urn: urn=self.absolute_url() - li="""\n""" + li="""\n""" for content in contents: - ret+=content[1].getRDF()+"\n" + ret+=self.unicodify(content[1].getRDF())+"\n" - ret+="""\n"""%urn + ret+="""\n"""%urn for content in contents: nurn=content[1].absolute_url() ret+=li%nurn - return ret+"" + return ret+"" def index_html(self): """standard page""" @@ -1804,7 +1820,8 @@ class ECHO_userFolder(UserFolder): return 1 return 0 -Globals.default__class_init__(ECHO_userFolder) +# ROC: problem with 2.12 +#Globals.default__class_init__(ECHO_userFolder) @@ -2055,8 +2072,8 @@ class ECHO_root(Folder,Persistent,Implic global key global value seq="" - if name=="RDF:Seq": - key=attrs.get('RDF:about') + if name=="rdf:Seq": + key=attrs.get('rdf:about') try: # teste ob liste x=seqs[key][0] except: @@ -2064,20 +2081,20 @@ class ECHO_root(Folder,Persistent,Implic seqs[key]=[] - elif name=="RDF:Description": - key=attrs.get('RDF:about') + elif name=="rdf:Description": + key=attrs.get('rdf:about') - elif name=="RDF:li": - name=attrs.get('RDF:resource') + elif name=="rdf:li": + name=attrs.get('rdf:resource') seqs[key].append(name) - elif name=="ECHONAVIGATION:type": + elif name=="echonavigation:type": value="type" - elif name=="ECHONAVIGATION:name": + elif name=="echonavigation:name": value="name" - elif name=="ECHONAVIGATION:linkClickable": + elif name=="echonavigation:linkClickable": value="linkClickable" def end_element(name): @@ -2158,17 +2175,17 @@ class ECHO_root(Folder,Persistent,Implic ret=getRDFDescription(self,self.absolute_url(),urn=urn) - li="""\n""" + li="""\n""" for content in contents: ret+=content[1].getRDF()+"\n" - ret+="""\n"""%urn + ret+="""\n"""%urn for content in contents: nurn=content[1].absolute_url() ret+=li%nurn - return ret+"" + return ret+"" def showContent(self,path):