--- OSAS/OSA_system/OSAS_addfiles.py 2006/02/14 16:25:22 1.43 +++ OSAS/OSA_system/OSAS_addfiles.py 2006/06/15 15:50:03 1.50 @@ -19,6 +19,7 @@ from Globals import package_home from xml.sax import make_parser from xml.sax.handler import ContentHandler +import sys import zLOG def spaces(depth): @@ -328,16 +329,24 @@ class OSAS_add_contextData(Folder): """Hinzufuegen zu einer Sammlung""" server=getattr(self,'serverUrl',self.REQUEST['SERVER_URL']) - + if path[0]=="/": #strip leading slash + urlpath=path[1:] + else: + urlpath=path try: - urllib.urlopen(server+"/"+path+"/index.meta") + urllib.urlopen(server+"/"+urlpath+"/index.meta") except: - zLOG.LOG("OSAS_addfiles (addContextData)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) - return self.REQUEST['SERVER_URL']+path+"/index.meta file has to exist!" + zLOG.LOG("OSAS_addfiles (addContextData)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) + return server+"/"+urlpath+"/index.meta file has to exist!" - links=[(path,'standard storage')] - + # old version for foxridge storage viewer + #links=[(path,'storage server view')] + # libcoll viewer with imagepath: needs pageimg directory + links=[('http://libcoll.mpiwg-berlin.mpg.de/libview?mode=imagepath&url=%s/pageimg'%path,'libcoll standard viewer (pageimg)')] + # libcoll viewer with texttool: needs texttool tag + links+=[('http://libcoll.mpiwg-berlin.mpg.de/libview?mode=texttool&url=%s/index.meta'%path,'libcoll standard viewer (texttool)')] + links+=OSAS_show.readContexts(path) # auslesen von contexten fuer den link #print "LINK",links #return links @@ -353,8 +362,13 @@ class OSAS_add_contextData(Folder): id=splitted[len(splitted)-1] title=splitted[len(splitted)-1] server=getattr(self,'serverUrl',self.REQUEST['SERVER_URL']) - - metalink=server+"/"+path+"/index.meta" + if path[0]=="/": #strip leading slash + urlpath=path[1:] + else: + urlpath=path + + + metalink=server+"/"+urlpath+"/index.meta" #link=TOBEDONE" """Hinzufuegen der Ressource""" @@ -372,13 +386,19 @@ class OSAS_add_contextData(Folder): return "An Error occured adding the resource\n", collection,params #print collection+"/"+id+"/copyIndex_meta2echo_resource" - + #TODO: fehler falls generate label oder title nicht funktioniert abfangen, bei ECHO geht das z.B. manchmal nicht. urllib.urlopen(collection+"/"+id+"/copyIndex_meta2echo_resource").read() #print "copy2res" - urllib.urlopen(collection+"/"+id+"/generate_label").read() - #print "label" - urllib.urlopen(collection+"/"+id+"/generate_title").read() - #print "title" + try: + urllib.urlopen(collection+"/"+id+"/generate_label").read() + except: + zLOG.LOG("OSAS_addfiles (addContextData2,label not generated)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) + try: + urllib.urlopen(collection+"/"+id+"/generate_title").read() + except: + zLOG.LOG("OSAS_addfiles (addContextData2,title not generated)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2]) + + return self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?path='+path) manage_options = Folder.manage_options+(