--- ECHO_content/ECHO_collection.py 2004/10/27 14:23:24 1.182
+++ ECHO_content/ECHO_collection.py 2004/10/27 16:05:55 1.185
@@ -1010,32 +1010,50 @@ class ECHO_resource(Folder,Persistent):
def createImageUrl(self,pn=1):
"""create ImageUrl"""
+
- resourcepath=readFieldFromXML(self.metalink,'resource','archive-path').replace('/mpiwg/online','')
+ resourcepath=readFieldFromXML(self.metalink,'resource','archive-path')
digiliburlprefix=readFieldFromXML(self.metalink,'texttool','digiliburlprefix')
images=readFieldFromXML(self.metalink,'texttool','image')
-
+
+
+ if (not resourcepath) or (not digiliburlprefix) or (not images):
+ zLOG.LOG("ECHO (createImageUrl)",zLOG.ERROR,"Cannot create ImageUrl for %s"%self.absolute_url())
+ return None
+ resourcepath=resourcepath.replace('/mpiwg/online','')
if not digiliburlprefix: digiliburlprefix="http://echo.mpiwg-berlin.mpg.de/zogilib?"
if (not images) or (not resourcepath): return None
return "%sfn=%s&pn=%i"%(digiliburlprefix,resourcepath+"/"+images,pn)
- def copyTitleToInfoXML(self):
+ def copyTitleToInfoXML(self,RESPONSE=None):
"""copy title from the resource"""
presentationXML=readFieldFromXML(self.metalink,'texttool','presentation')
resourcepath=readFieldFromXML(self.metalink,'resource','archive-path')
- print os.path.join(resourcepath,presentationXML)
- fh=file(os.path.join(resourcepath,presentationXML),'w')
- fh.write("""
-
- %s
-
- yes
- """%self.title)
- fh.close()
-
+ if (not presentationXML) or (not resourcepath):
+ if RESPONSE:
+ RESPONSE.write("Error: %s\n"%self.getId())
+ else:
+ return None,self.absolute_url()
+
+ try:
+ fh=file(os.path.join(resourcepath,presentationXML),'w')
+ fh.write("""
+
+ %s
+
+ yes
+ """%self.title)
+ fh.close()
+ return 1,self.getId()
+ except:
+ if RESPONSE:
+ RESPONSE.write("Error: %s\n"%self.getId())
+ else:
+ return None,self.absolute_url()
+
def setStartPage(self,startpage=None,RESPONSE=None):
"""set start page, if no startpage defined use the generic one of the resource"""
@@ -1177,17 +1195,17 @@ class ECHO_resource(Folder,Persistent):
"""getFullTextXML; gives the FullText as an XML Document, and if somthing goes wrong."""
try:
- zLOG.LOG("ECHO Fulltext",zLOG.INFO,"open %s"%self.metalink)
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"open %s"%self.metalink)
fh=ECHO_helpers.urlopen(self.metalink)
- zLOG.LOG("ECHO Fulltext",zLOG.INFO,"opened %s"%self.metalink)
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"opened %s"%self.metalink)
dom=xml.dom.minidom.parse(fh)
texttools=dom.getElementsByTagName('texttool')
text=texttools[0].getElementsByTagName('text')
texturl=getText(text[0].childNodes)
- zLOG.LOG("ECHO Fulltext",zLOG.INFO,"found %s"%texturl)
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"found %s"%texturl)
fh.close()
- zLOG.LOG("ECHO Fulltext",zLOG.INFO,"closed fh")
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"closed fh")
#keine url
if not (texturl.split(":")[0] in ['http','ftp','file']):
if not noredirect:
@@ -2213,18 +2231,26 @@ class ECHO_collection(Folder, Persistent
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
- def copyTitleToInfoXMLFolder(self):
+ def copyTitleToInfoXMLFolder(self,RESPONSE=None):
"""copy title into the title field of info.xml
author and date werden leer!!!
"""
+
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1)
-
+
+
for resource in resources:
-
- resource[1].copyTitleToInfoXML()
-
+ ret,txt=resource[1].copyTitleToInfoXML()
+ if (not ret) and RESPONSE:
+ RESPONSE.write("error: %s\n"%txt)
+ if ret and RESPONSE:
+ RESPONSE.write("ok: %s\n"%txt)
+
+ #zLOG.LOG("ECHO (copyTitleToInfoXMLFolder)",zLOG.INFO,txt)
if RESPONSE is not None:
+ RESPONSE.write("done!\n")
+ RESPONSE.close()
RESPONSE.redirect('manage_main')
def copySearchFields(self,RESPONSE=None):