--- ECHO_content/ECHO_collection.py 2004/05/07 14:00:13 1.62 +++ ECHO_content/ECHO_collection.py 2004/05/07 14:51:02 1.65 @@ -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""" @@ -655,16 +677,20 @@ class ECHO_collection(Folder, Persistent 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') @@ -876,6 +902,20 @@ 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): @@ -889,16 +929,14 @@ class ECHO_collection(Folder, Persistent for coordtemp in object.coords: if len(coordtemp)>3: coord=coordtemp[0:4] + label="" 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]) - + 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.getViewClassification()]) except: """nothing""" @@ -1092,7 +1130,42 @@ class ECHO_root(Folder,Persistent,Implic return "changed all contenttypes in: "+self.title - + + + def patchViewClassification(self,obj=None): + """setze viewClassification heuristisch""" + + def checkIfArrow(obj): + if hasattr(obj,'coords'): + for coordtemp in obj.coords: + print obj.title,len(coordtemp) + if (len(coordtemp)>4) and not (coordtemp[4]==''): + return 4 + return None + return None + + if not obj: + obj = self + + entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection','ECHO_group']) + + for entry in entries: + + if checkIfArrow(entry[1]): + print "VP" + setattr(entry[1],'viewClassification','view point') + else: + print "area" + setattr(entry[1],'viewClassification','area') + + #entry[1].contentType == entry[1].content_type + + if entry[1].meta_type in ['ECHO_collection','ECHO_group']: + entry[1].patchViewClassification(entry[1]) + + + return "changed all contenttypes in: "+self.title + def ECHO_newViewerLink(self,obj=None): """change links (:86 faellt weg)"""