--- ECHO_content/ECHO_collection.py 2003/11/25 11:19:47 1.1.1.1 +++ ECHO_content/ECHO_collection.py 2004/01/27 13:33:27 1.11 @@ -8,7 +8,6 @@ class ECHO_resource contains information class ECHO_externalLink contains information on externalLinks - """ import string import OFS.Image @@ -30,6 +29,10 @@ import urllib import xml.dom.minidom +#List of different types for the graphical linking viewer +viewClassificationListMaster=['view point','area'] + + def toList(field): """Einzelfeld in Liste umwandeln""" if type(field)==StringType: @@ -90,10 +93,12 @@ def readMetadata(url): return metadict,"" -def setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords): +def setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coordstrs,viewClassification=""): """Allegemeine Informationen zu einer ECHO Collection""" + self.viewClassification=viewClassification + self.label = label self.title=title self.description=description @@ -108,9 +113,22 @@ def setECHO_CollectionInformation(self,c self.scientific_Information.scientific_Classification.science=science self.scientific_Information.scientific_Classification.practice=practice - + coords=[] #coordinates of for rectangles - self.coords=coords + + #print "cs", coordstrs + if coordstrs: + for coordstr in coordstrs: + print "cs", coordstr + try: + temco=coordstr.split(",") + except: + temco=[] + #temco.append(angle) + coords.append(temco) + + + self.coords=coords[0:] class scientificClassification(SimpleItem,Persistent,Implicit): @@ -163,7 +181,21 @@ class ECHO_resource(Folder): """ECHO Ressource""" meta_type='ECHO_resource' + viewClassificationList=viewClassificationListMaster + + def getViewClassification(self): + if hasattr(self,'viewClassification'): + return self.viewClassification + else: + return "" + def getCredits(self): + """Ausgabe der credits""" + if self.credits: + return self.credits + else: + return [] + def __init__(self,id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords): self.id = id @@ -178,10 +210,21 @@ class ECHO_resource(Folder): self.description=description self.content_type=content_type self.responsible=responsible - coordsnew=[ string.split(x,",") for x in coords] + + if coords: + coordsnew=[ string.split(x,",") for x in coords] + else: + coordsnew=[] + self.coords=coordsnew - + + def getCoords(self): + try: + return [string.join(x,",") for x in self.coords] + except: + return [] + def ECHO_resource_config(self): """Main configuration""" @@ -195,12 +238,13 @@ class ECHO_resource(Folder): return pt() - def changeECHO_resource(self,metalink,link,context,science,practice,source_type,period,title,label,description,content_type,responsible,credits,weight,coords,RESPONSE=None): + def changeECHO_resource(self,metalink,link,context,science,practice,source_type,period,title,label,description,content_type,responsible,credits,weight,viewClassification="",coords="",RESPONSE=None): + """Änderung der Properties""" - setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords) + setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords,viewClassification) self.link=link @@ -213,10 +257,29 @@ class ECHO_resource(Folder): manage_options = Folder.manage_options+( {'label':'Main Config','action':'ECHO_resource_config'}, {'label':'Metadata','action':'ECHO_getResourceMD'}, - + {'label':'Graphics','action':'ECHO_graphicEntry'}, ) - + def ECHO_graphicEntry(self): + """DO nothing""" + if 'overview' in self.aq_parent.__dict__.keys(): + pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self) + return pt() + else: + return "NO OVERVIEW GRAPHICS" + + def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None): + """Enter coords""" + coords=self.coords + temco=coordstr.split(",") + temco.append(angle) + coords.append(temco) + + self.coords=coords[0:] + #pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self) + if RESPONSE is not None: + RESPONSE.redirect('ECHO_graphicEntry') + def ECHO_getResourceMD(self,template="yes"): """Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" (metadict, error)=readMetadata(self.metalink) @@ -260,7 +323,9 @@ def manage_AddECHO_resourceForm(self): return pt() -def manage_AddECHO_resource(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,metalink,credits,weight,coords,RESPONSE=None): + +def manage_AddECHO_resource(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,metalink,credits,weight,coords=None,RESPONSE=None): + """nothing yet""" scientificClassificationObj=scientificClassification(context,science,practice) @@ -305,7 +370,7 @@ class ECHO_externalLink(Folder): if not hasattr(self,'weight'): self.weight="" if not hasattr(self,'coords'): - print "HI" + self.coords=[''] print "G",self.coords @@ -418,11 +483,16 @@ class ECHO_collection(Folder, Persistent def getCoords(self): try: - return [ string.join(x,",") for x in self.coords] + + x= [string.join(x,",") for x in self.coords] + return x + except: + return [] + def __init__(self,id,title,label,description,content_type,responsible,credits,weight,sortfield,coords): - print "CO",coords + #print "CO",coords self.id = id """Festlegen der ID""" @@ -454,11 +524,16 @@ class ECHO_collection(Folder, Persistent else: return "NO OVERVIEW GRAPHICS" - def ECHO_enterCoords(self,coordstr): + def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None): """Enter coords""" - self.coords.append(coordstr.split(",")) - pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self) - return pt() + coords=self.coords + temco=coordstr.split(",") + temco.append(angle) + coords.append(temco) + self.coords=coords[0:] + #pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self) + if RESPONSE is not None: + RESPONSE.redirect('ECHO_graphicEntry') security.declarePublic('ECHO_Collection_config') @@ -480,11 +555,14 @@ class ECHO_collection(Folder, Persistent security.declarePublic('changeECHO_Collection') - def changeECHO_Collection(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords,sortfield="weight",RESPONSE=None): - """Änderung der Properties""" + def changeECHO_Collection(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,sortfield="weight",coords="",RESPONSE=None): + + """Änderung der Properties""" + #print "HI",coords coordsnew=[ string.split(x,",") for x in coords] + #print "HO",coordsnew setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coordsnew) self.sortfield=sortfield @@ -504,6 +582,7 @@ class ECHO_collection(Folder, Persistent if 'index.html' in self.__dict__.keys(): return getattr(self,'index.html')() elif 'overview' in self.__dict__.keys(): + #print "HI" return self.showOverview() @@ -511,6 +590,12 @@ class ECHO_collection(Folder, Persistent pt.content_type="text/html" return pt() + def getCredits(self): + """Ausgabe der credits""" + if self.credits: + return self.credits + else: + return [] def getGraphicCoords(self): """Give list of coordinates""" @@ -521,16 +606,23 @@ class ECHO_collection(Folder, Persistent #print "OB:",object try: - print "MT:",object.meta_type + #print "MT:",object.meta_type if object.meta_type in subColTypes: - for coord in object.coords: - if len(coord)==4: - ids.append([string.join(coord,", "),object.getId()]) - + #print "MT:",object.meta_type,object.getId() + for coordtemp in object.coords: + if len(coordtemp)>3: + coord=coordtemp[0:4] + if hasattr(object,'title'): + if not object.title=="": + ids.append([string.join(coord,", "),object.getId(),object.title]) + else: + ids.append([string.join(coord,", "),object.getId(),object.getId()]) + else: + ids.append([string.join(coord,", "),object.getId(),object.getId()]) except: """nothing""" - print "IDS",ids + #print "IDS",ids return ids def getSubCols(self,sortfield="weight"): @@ -578,7 +670,7 @@ def manage_AddECHO_collectionForm(self): return pt() -def manage_AddECHO_collection(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,sortfield,coords,RESPONSE=None): +def manage_AddECHO_collection(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,weight,sortfield,coords,credits=None,RESPONSE=None): """nothing yet""" scientificClassificationObj=scientificClassification(context,science,practice) @@ -617,6 +709,7 @@ class ECHO_root(Folder,Persistent,Implic except: """nothing""" + return ids def getCollectionTree(self):