--- ECHO_content/ECHO_collection.py 2004/05/06 13:29:45 1.56 +++ ECHO_content/ECHO_collection.py 2004/05/07 16:37:09 1.68 @@ -76,6 +76,28 @@ def getText(nodelist): return rc +def sendFile(self, filename, type): + """sends an object or a local file (in the product) as response""" + paths = filename.split('/') + object = self + # look for an object called filename + for path in paths: + if hasattr(object, path): + object = getattr(object, path) + else: + object = None + break + if object: + # if the object exists then send it + object() + else: + # send a local file with the given content-type + fn = os.path.join(package_home(globals()), filename) + self.REQUEST.RESPONSE.setHeader("Content-Type", type) + self.REQUEST.RESPONSE.write(file(fn).read()) + return + + def readMetadata(url): """Methoden zum Auslesen der Metadateninformation zu einer Resource Vorerst noch Typ bib""" @@ -354,7 +376,7 @@ class ECHO_resource(Folder): coordsnew=[] setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) - + self.viewClassification=viewClassification self.coords=coordsnew[0:] self.link=link self.metalink=metalink @@ -577,6 +599,8 @@ class ECHO_collection(Folder, Persistent security=ClassSecurityInfo() meta_type='ECHO_collection' + displayTypes=displayTypes + def getTitle(self): """title""" return self.title.encode('utf-8') @@ -642,27 +666,31 @@ class ECHO_collection(Folder, Persistent element=getattr(object,entry) try: if element.meta_type in ["ECHO_collection","ECHO_group"]: - collections+="" + collections+="" collections+=getCollection(element,depth)+"\n" except: """nothing""" return collections - - return ""+getCollection(self)+"" + ret="""""" + return ret+""+getCollection(self)+"" def createJavaScript(self): """CreateJava""" - ret=javaScriptMain + #ret=javaScriptMain + ret="" - dynamical="" + dynamical="\n" for ob in self.getGraphicCoords(): if ob[4][4] == "": - dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0]) + #dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0]) + dynamical+="""addArea('%s', 'overview', %s, 'area');\n"""%(ob[1],ob[0]) else: - dynamical+="""Coords.push(new Coord('%s', Img, %s));//%s\n"""%(ob[1],ob[0],ob[4][4]) - dynamical+="ShowArrow(new getObj('i.%s'),Img,%s);\n"%(ob[1],ob[0]) - ret+=javaHandler%dynamical + dynamical+="""addArea('%s', 'overview', %s, 'arrow');\n"""%(ob[1],ob[0]) + #dynamical+="""Coords.push(new Coord('%s', Img, %s));//%s\n"""%(ob[1],ob[0],ob[4][4]) + #dynamical+="ShowArrow(new getObj('i.%s'),Img,%s);\n"%(ob[1],ob[0]) + #ret+=javaHandler%dynamical + ret+=dynamical return ret security.declarePublic('getCreditObject') @@ -874,32 +902,40 @@ class ECHO_collection(Folder, Persistent else: return [] + def area_img(self): + """area image""" + sendFile(self, 'images/red.gif', 'image/gif') + return + + def hl_lib_js(self): + """javascript""" + sendFile(self, 'js/hl_lib.js', 'text/plain') + return + + def js_lib_js(self): + """javascript""" + sendFile(self, 'js/js_lib.js', 'text/plain') + return def getGraphicCoords(self): """Give list of coordinates""" - subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] + subColTypes=['ECHO_collection','ECHO_resource'] ids=[] - for entry in self.__dict__.keys(): - object=getattr(self,entry) - try: - if object.meta_type in subColTypes: - for coordtemp in object.coords: - if len(coordtemp)>3: - coord=coordtemp[0:4] - if hasattr(object,'label') and not object.label=="": - ids.append([string.join(coord,", "),object.getId(),object.label,object,coordtemp]) - elif hasattr(object,'title'): - if not object.title=="": - ids.append([string.join(coord,", "),object.getId(),object.title,object,coordtemp]) - else: - ids.append([string.join(coord,", "),object.getId(),object.getId(),object,coordtemp]) - else: - ids.append([string.join(coord,", "),object.getId(),object.getId(),object,coordtemp]) - - except: - """nothing""" - + for entrySearch in self.ZopeFind(self,obj_metatypes=subColTypes): + object=entrySearch[1] + if hasattr(object,'coords'): + for coordtemp in object.coords: + if len(coordtemp)>3: + coord=coordtemp[0:4] + label="" + if hasattr(object,'label') and not object.label=="": + label=object.label + elif hasattr(object,'title') and not object.title=="": + label=object.title + else: + label=object.getId() + ids.append([string.join(coord,", "),object.getId(),label,object,coordtemp,object.viewClassification]) return ids @@ -940,8 +976,8 @@ class ECHO_group(ECHO_collection): def index_html(self): """standard page""" displayedObjects=self.ZopeFind(self,obj_metatypes=displayTypes) - if len(displayedObjects)==1: # nur ein Object dann redirect auf dieses Object - return self.REQUEST.RESPONSE.redirect(displayedObjects[0][1].absolute_url()) + #if (len(displayedObjects)==1) and (displayedObjects[0][1].meta_type=="ECHO_collection"): # nur ein Object dann redirect auf dieses Object + # return self.REQUEST.RESPONSE.redirect(displayedObjects[0][1].absolute_url()) if 'index.html' in self.__dict__.keys(): return getattr(self,'index.html')() @@ -1054,14 +1090,22 @@ class ECHO_root(Folder,Persistent,Implic else: retStr="