--- ECHO_content/ECHO_collection.py 2004/12/02 17:04:15 1.197 +++ ECHO_content/ECHO_collection.py 2004/12/02 17:17:29 1.198 @@ -75,12 +75,10 @@ regexpPage = re.compile(patternPage, re. -def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs,viewClassification=""): +def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs="",viewClassification=""): """Allegemeine Informationen zu einer ECHO Collection""" - self.viewClassification=viewClassification - self.label = label self.title=title self.description=description @@ -89,22 +87,6 @@ def setECHO_collectionInformation(self,t self.credits=toList(credits) self.weight=weight - coords=[] - #coordinates of for rectangles - - - if coordstrs: - for coordstr in coordstrs: - - try: - temco=coordstr.split(",") - except: - temco=[] - - coords.append(temco) - - - self.coords=coords[0:] class ECHO_copyright(Folder,ECHO_basis): """Copyright informationen""" @@ -1027,14 +1009,7 @@ class ECHO_resource(Folder,Persistent,EC def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None): """Aenderung der Properties""" - try: - coordsnew=[ string.split(x,",") for x in coords] - except: - coordsnew=[] - - setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) - self.viewClassification=viewClassification - self.coords=coordsnew[0:] + setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) self.link=link self.metalink=metalink @@ -1411,16 +1386,9 @@ class ECHO_externalLink(Folder,ECHO_basi def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None): - """Aenderung der Properties""" - try: - coordsnew=[ string.split(x,",") for x in coords] - except: - coordsnew=[] - - setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coords) + setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) - self.coords=coordsnew[0:] self.link=link if RESPONSE is not None: RESPONSE.redirect('manage_main') @@ -2092,9 +2060,6 @@ class ECHO_collection(Folder, Persistent if not hasattr(self,'sortfield'): self.sortfield="weight" - if not hasattr(self,'coords'): - self.coords=[] - pt=zptFile(self, 'zpt/ChangeECHO_collection.zpt') return pt() @@ -2115,22 +2080,10 @@ class ECHO_collection(Folder, Persistent self.secondaryLinkTitle=secondaryLinkTitle self.imageTag=imageTag self.bgcolour=bgcolour - self.viewClassification=viewClassification self.location=location self.isAlwaysClickable=isAlwaysClickable - - if coords: - coordsnew=[ string.split(x,",") for x in coords] - self.coords=coordsnew[0:] - else: - coordsnew=None - self.coords=None - setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) - try: - self.coords=coordsnew[0:] # HACK fehler in setECHO_collection - except: - """none""" + setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) self.sortfield=sortfield @@ -2241,45 +2194,6 @@ class ECHO_collection(Folder, Persistent parent._delObject(id) return "Done" - def repairCoords(self): - """updates map coordinates to new class objects""" - msg = "" - for cols in self.ZopeFind(self, obj_metatypes=['ECHO_collection','ECHO_resource'], search_sub=1): - col = cols[1] - if not hasattr(col, 'coords'): - continue - print "fixing: ", col.id - msg += "fixing: "+col.id+"\n" - coords = col.coords - if len(coords) > 0: - # delete old MapAreas - for areas in self.ZopeFind(col, obj_metatypes=['MapArea']): - #area = areas[1] - id = areas[0] - print " deleting: ", id - msg += " deleting: "+id+"\n" - col._delObject(id) - # add new MapAreas - areacnt = 0 - for coord in coords: - if len(coord) < 4: - continue - type = col.viewClassification - if type == 'view point': - type = 'arrow' - if type is None: - if len(coord) > 4: - type = 'arrow' - else: - type = 'area' - newid = "a%02d"%areacnt - areacnt += 1 - area = MapArea(newid, coord, type=type) - print " adding: ", newid - msg += " adding: "+newid+"\n" - col.addMapArea(area) - msg += "\nDone!" - return msg getSubCols = ECHO_helpers.getSubCols @@ -2383,14 +2297,7 @@ class ECHO_group(ECHO_collection): self.bgcolour=bgcolour self.logo=logo - if coords: - coordsnew=[ string.split(x,",") for x in coords] - self.coords=coordsnew[0:] - else: - coordsnew=None - self.coords=None - - setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) + setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight) @@ -2983,6 +2890,11 @@ class ECHO_root(Folder,Persistent,Implic return "changed all contenttypes in: "+self.title + def repairAllCoords(self): + """updates map coordinates on the same and sublevels""" + return repairCoords(self) + + def patchViewClassification(self,obj=None): """setze viewClassification heuristisch""" @@ -3017,23 +2929,15 @@ class ECHO_root(Folder,Persistent,Implic def deleteCache(self,obj=None,RESPONSE=None): """setze alle collections auf cache = CacheManager""" - - if not obj: obj = self - entries=obj.ZopeFind(obj,search_sub=1) - for entry in entries: if hasattr(entry[1],'_v_hash'): entry[1]._v_hash=None - - - return "changed all CM in: "+self.title - security.declarePublic('ECHO_newViewerLink') def ECHO_newViewerLink(self,obj=None): @@ -3749,3 +3653,42 @@ def manage_addECHO_institution(self, id, REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id +def repairCoords(self): + """updates map coordinates to new MapArea objects""" + msg = "" + for cols in self.ZopeFind(self, obj_metatypes=['ECHO_collection','ECHO_resource'], search_sub=1): + col = cols[1] + if not hasattr(col, 'coords'): + continue + print "fixing: ", col.id + msg += "fixing: "+col.id+"\n" + coords = col.coords + if len(coords) > 0: + # delete old MapAreas + for areas in self.ZopeFind(col, obj_metatypes=['MapArea']): + #area = areas[1] + id = areas[0] + print " deleting: ", id + msg += " deleting: "+id+"\n" + col._delObject(id) + # add new MapAreas + areacnt = 0 + for coord in coords: + if len(coord) < 4: + continue + type = col.viewClassification + if type == 'view point': + type = 'arrow' + if type is None: + if len(coord) > 4: + type = 'arrow' + else: + type = 'area' + newid = "a%02d"%areacnt + areacnt += 1 + area = MapArea(newid, coord, type=type) + print " adding: ", newid + msg += " adding: "+newid+"\n" + col.addMapArea(area) + msg += "\nDone!" + return msg