Annotation of ECHO_content/ECHO_collection.py.~1.11.~, revision 1.1
1.1 ! dwinter 1:
! 2: """Echo collection provides the classes for the ECHO content web-site.
! 3:
! 4: class ECHO_collection is the basis class for an ECHO collection.
! 5:
! 6: class ECHO_resource contains information on ECHO resources (e.g. an Display environment for Metadata
! 7:
! 8: class ECHO_externalLink contains information on externalLinks
! 9:
! 10:
! 11: """
! 12: import string
! 13: import OFS.Image
! 14: from types import *
! 15: from OFS.Image import Image
! 16: from Globals import DTMLFile
! 17: from OFS.Folder import Folder
! 18: from OFS.SimpleItem import SimpleItem
! 19: from AccessControl import ClassSecurityInfo
! 20: from Globals import InitializeClass
! 21: from Globals import DTMLFile
! 22: from Products.PageTemplates.PageTemplateFile import PageTemplateFile
! 23: from Products.PageTemplates.PageTemplate import PageTemplate
! 24: from Globals import Persistent
! 25: from Acquisition import Implicit
! 26:
! 27:
! 28: import urllib
! 29: import xml.dom.minidom
! 30:
! 31:
! 32: #List of different types for the graphical linking viewer
! 33: viewClassificationListMaster=['view point','area']
! 34:
! 35:
! 36: def toList(field):
! 37: """Einzelfeld in Liste umwandeln"""
! 38: if type(field)==StringType:
! 39: return [field]
! 40: else:
! 41: return field
! 42:
! 43: def getText(nodelist):
! 44:
! 45: rc = ""
! 46: for node in nodelist:
! 47: if node.nodeType == node.TEXT_NODE:
! 48: rc = rc + node.data
! 49: return rc
! 50:
! 51:
! 52: def readMetadata(url):
! 53: """Methoden zum Auslesen der Metadateninformation zu einer Resource
! 54: Vorerst noch Typ bib"""
! 55:
! 56: metadict={}
! 57: try:
! 58: geturl=""
! 59: for line in urllib.urlopen(url).readlines():
! 60: geturl=geturl+line
! 61:
! 62:
! 63: except:
! 64: return (None,"Cannot open: "+url)
! 65:
! 66: try:
! 67: dom=xml.dom.minidom.parseString(geturl)
! 68: except:
! 69: return (None,"Cannot parse: "+url+"<br>"+geturl)
! 70:
! 71: metanode=dom.getElementsByTagName('bib')
! 72: metadict['bib_type']='Book'
! 73: if len(metanode)==0:
! 74: metanode=dom.getElementsByTagName('archimedes')
! 75: metadict['bib_type']='Archimedes'
! 76: #print "HELLO"
! 77:
! 78: if not len(metanode)==0:
! 79: metacontent=metanode[0].childNodes
! 80:
! 81: try:
! 82: metadict['bib_type']=getText(dom.getElementsByTagName('bib')[0].attributes['type'].childNodes)
! 83: except:
! 84: """nothing"""
! 85:
! 86: for node in metacontent:
! 87: try:
! 88: metadict[node.tagName.lower()]=getText(node.childNodes)
! 89: except:
! 90: """nothing"""
! 91:
! 92: #print metadict
! 93: return metadict,""
! 94:
! 95:
! 96: def setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coordstrs,viewClassification=""):
! 97:
! 98: """Allegemeine Informationen zu einer ECHO Collection"""
! 99:
! 100: self.viewClassification=viewClassification
! 101:
! 102: self.label = label
! 103: self.title=title
! 104: self.description=description
! 105: self.content_type=content_type
! 106: self.responsible=responsible
! 107: self.credits=toList(credits)
! 108: self.weight=weight
! 109:
! 110: self.scientific_Information.source_type=source_type
! 111: self.scientific_Information.period=period
! 112: self.scientific_Information.scientific_Classification.context=context
! 113: self.scientific_Information.scientific_Classification.science=science
! 114: self.scientific_Information.scientific_Classification.practice=practice
! 115:
! 116: coords=[]
! 117: #coordinates of for rectangles
! 118:
! 119: #print "cs", coordstrs
! 120: if coordstrs:
! 121: for coordstr in coordstrs:
! 122: print "cs", coordstr
! 123: try:
! 124: temco=coordstr.split(",")
! 125: except:
! 126: temco=[]
! 127: #temco.append(angle)
! 128: coords.append(temco)
! 129:
! 130:
! 131: self.coords=coords[0:]
! 132:
! 133:
! 134: class scientificClassification(SimpleItem,Persistent,Implicit):
! 135: """subclass"""
! 136: security=ClassSecurityInfo()
! 137:
! 138: def __init__(self,context,science,practice):
! 139: self.context=context
! 140: self.science=science
! 141: self.practice=practice
! 142: self.id="scientific_Classification"
! 143:
! 144: security.declarePublic('get_context')
! 145: def get_context(self):
! 146: return self.context
! 147:
! 148: security.declarePublic('get_science')
! 149: def get_science(self):
! 150: return self.science
! 151:
! 152: security.declarePublic('get_practice')
! 153: def get_practice(self):
! 154: return self.practice
! 155:
! 156:
! 157: class scientificInformation(Folder,Persistent,Implicit):
! 158: """subclass scientificInformation"""
! 159: security=ClassSecurityInfo()
! 160:
! 161:
! 162:
! 163: def __init__(self,source_type,period):
! 164:
! 165: self.id="scientific_Information"
! 166: self.source_type=source_type
! 167: self.period=period
! 168:
! 169:
! 170:
! 171: security.declarePublic('get_source_type')
! 172: def get_source_type(self):
! 173: return self.source_type
! 174:
! 175: security.declarePublic('get_period')
! 176: def get_period(self):
! 177: return self.period
! 178:
! 179:
! 180: class ECHO_resource(Folder):
! 181: """ECHO Ressource"""
! 182: meta_type='ECHO_resource'
! 183:
! 184: viewClassificationList=viewClassificationListMaster
! 185:
! 186: def getViewClassification(self):
! 187: if hasattr(self,'viewClassification'):
! 188: return self.viewClassification
! 189: else:
! 190: return ""
! 191:
! 192: def getCredits(self):
! 193: """Ausgabe der credits"""
! 194: if self.credits:
! 195: return self.credits
! 196: else:
! 197: return []
! 198:
! 199: def __init__(self,id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords):
! 200:
! 201: self.id = id
! 202: """Festlegen der ID"""
! 203:
! 204: self.label = label
! 205: self.link= link
! 206: self.metalink=metalink
! 207: self.title=title
! 208: self.weight=weight
! 209: self.credits=toList(credits)
! 210: self.description=description
! 211: self.content_type=content_type
! 212: self.responsible=responsible
! 213:
! 214: if coords:
! 215: coordsnew=[ string.split(x,",") for x in coords]
! 216: else:
! 217: coordsnew=[]
! 218:
! 219: self.coords=coordsnew
! 220:
! 221:
! 222: def getCoords(self):
! 223: try:
! 224: return [string.join(x,",") for x in self.coords]
! 225: except:
! 226: return []
! 227:
! 228:
! 229: def ECHO_resource_config(self):
! 230: """Main configuration"""
! 231:
! 232: if not hasattr(self,'weight'):
! 233: self.weight=""
! 234: if not hasattr(self,'coords'):
! 235: self.coords=[]
! 236:
! 237: pt=PageTemplateFile('Products/ECHO_content/ChangeECHO_resource.zpt').__of__(self)
! 238: return pt()
! 239:
! 240:
! 241: def changeECHO_resource(self,metalink,link,context,science,practice,source_type,period,title,label,description,content_type,responsible,credits,weight,viewClassification="",coords="",RESPONSE=None):
! 242:
! 243:
! 244: """Änderung der Properties"""
! 245:
! 246:
! 247: setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords,viewClassification)
! 248:
! 249:
! 250: self.link=link
! 251: self.metalink=metalink
! 252:
! 253: if RESPONSE is not None:
! 254: RESPONSE.redirect('manage_main')
! 255:
! 256:
! 257: manage_options = Folder.manage_options+(
! 258: {'label':'Main Config','action':'ECHO_resource_config'},
! 259: {'label':'Metadata','action':'ECHO_getResourceMD'},
! 260: {'label':'Graphics','action':'ECHO_graphicEntry'},
! 261: )
! 262:
! 263: def ECHO_graphicEntry(self):
! 264: """DO nothing"""
! 265: if 'overview' in self.aq_parent.__dict__.keys():
! 266: pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self)
! 267: return pt()
! 268: else:
! 269: return "NO OVERVIEW GRAPHICS"
! 270:
! 271: def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None):
! 272: """Enter coords"""
! 273: coords=self.coords
! 274: temco=coordstr.split(",")
! 275: temco.append(angle)
! 276: coords.append(temco)
! 277:
! 278: self.coords=coords[0:]
! 279: #pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self)
! 280: if RESPONSE is not None:
! 281: RESPONSE.redirect('ECHO_graphicEntry')
! 282:
! 283: def ECHO_getResourceMD(self,template="yes"):
! 284: """Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource"""
! 285: (metadict, error)=readMetadata(self.metalink)
! 286:
! 287: #print "BLA"
! 288:
! 289: if not error=="": #Fehler beim Auslesen des Metafiles
! 290: return "ERROR:",error
! 291: for key in metadict.keys():#Hinzufügen der Felder
! 292:
! 293: setattr(self,key,metadict[key].encode('ascii','replace'))
! 294:
! 295:
! 296: self.metadata=metadict.keys()
! 297: #return "BLUccssB"
! 298: self.label=self.generate_label()
! 299:
! 300: if template=="yes":
! 301: pt=PageTemplateFile('Products/ECHO_content/ECHO_resourceMD.zpt').__of__(self)
! 302: return pt()
! 303:
! 304: def ECHO_getMD(self,item):
! 305: """Ausgabe der MD"""
! 306: return getattr(self,item)
! 307:
! 308: def index_html(self):
! 309: """standard page"""
! 310:
! 311: return self.REQUEST.RESPONSE.redirect(self.link)
! 312:
! 313: def generate_label(self):
! 314: """Erzeugt_standard_Label aus Template"""
! 315: pt=getattr(self,"label_template_"+self.bib_type)
! 316: #return pt
! 317: #pt.content_type="text/html; charset=utf-8"
! 318: return pt()
! 319:
! 320: def manage_AddECHO_resourceForm(self):
! 321: """Nothing yet"""
! 322: pt=PageTemplateFile('Products/ECHO_content/AddECHO_resourceForm.zpt').__of__(self)
! 323: return pt()
! 324:
! 325:
! 326:
! 327: 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):
! 328:
! 329:
! 330: """nothing yet"""
! 331: scientificClassificationObj=scientificClassification(context,science,practice)
! 332:
! 333: scientificInformationObj=scientificInformation(source_type,period)
! 334:
! 335:
! 336: newObj=ECHO_resource(id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords)
! 337:
! 338: self._setObject(id,newObj)
! 339: getattr(self,id)._setObject('scientific_Information',scientificInformationObj)
! 340: getattr(self,id).scientific_Information._setObject('scientific_Classification',scientificClassificationObj)
! 341: if RESPONSE is not None:
! 342: RESPONSE.redirect('manage_main')
! 343:
! 344:
! 345: class ECHO_externalLink(Folder):
! 346: """Link zu einer externen Ressource"""
! 347: security=ClassSecurityInfo()
! 348: meta_type='ECHO_externalLink'
! 349:
! 350:
! 351: def __init__(self,id,link,title,label,description,content_type,responsible,credits,weight,coords):
! 352:
! 353: self.id = id
! 354: """Festlegen der ID"""
! 355:
! 356: self.credits=toList(credits)
! 357: self.label = label
! 358: self.link= link
! 359: self.title=title
! 360: self.weight=weight
! 361: self.description=description
! 362: self.content_type=content_type
! 363: self.responsible=responsible
! 364: coordsnew=[ string.split(x,",") for x in coords]
! 365: self.coords=coordsnew
! 366:
! 367: def ECHO_externalLink_config(self):
! 368: """Main configuration"""
! 369:
! 370: if not hasattr(self,'weight'):
! 371: self.weight=""
! 372: if not hasattr(self,'coords'):
! 373:
! 374: self.coords=['']
! 375: print "G",self.coords
! 376:
! 377: pt=PageTemplateFile('Products/ECHO_content/ChangeECHO_externalLink.zpt').__of__(self)
! 378: return pt()
! 379:
! 380:
! 381: def changeECHO_externalLink(self,link,context,science,practice,source_type,period,title,label,description,content_type,responsible,credits,weight,coords,RESPONSE=None):
! 382:
! 383: """Änderung der Properties"""
! 384:
! 385:
! 386: setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coords)
! 387:
! 388:
! 389: self.link=link
! 390: if RESPONSE is not None:
! 391: RESPONSE.redirect('manage_main')
! 392:
! 393:
! 394: manage_options = Folder.manage_options+(
! 395: {'label':'Main Config','action':'ECHO_externalLink_config'},
! 396: )
! 397:
! 398: def index_html(self):
! 399: """standard page"""
! 400:
! 401: return self.REQUEST.RESPONSE.redirect(self.link)
! 402:
! 403: def manage_AddECHO_externalLinkForm(self):
! 404: """Nothing yet"""
! 405: pt=PageTemplateFile('Products/ECHO_content/AddECHO_externalLinkForm.zpt').__of__(self)
! 406: return pt()
! 407:
! 408:
! 409: def manage_AddECHO_externalLink(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,link,credits,weight,coords,RESPONSE=None):
! 410:
! 411: """nothing yet"""
! 412: scientificClassificationObj=scientificClassification(context,science,practice)
! 413:
! 414: scientificInformationObj=scientificInformation(source_type,period)
! 415:
! 416:
! 417: newObj=ECHO_externalLink(id,link,title,label,description,content_type,responsible,credits,weight,coords)
! 418:
! 419: self._setObject(id,newObj)
! 420: getattr(self,id)._setObject('scientific_Information',scientificInformationObj)
! 421: getattr(self,id).scientific_Information._setObject('scientific_Classification',scientificClassificationObj)
! 422: if RESPONSE is not None:
! 423: RESPONSE.redirect('manage_main')
! 424:
! 425:
! 426: class ECHO_collection(Folder, Persistent, Implicit):
! 427: """ECHO Collection"""
! 428: security=ClassSecurityInfo()
! 429: meta_type='ECHO_collection'
! 430:
! 431:
! 432:
! 433: security.declarePublic('getCreditObject')
! 434: def getCreditObject(self,name):
! 435: """credit id to credititem"""
! 436: return getattr(self.partners,name)
! 437:
! 438: security.declarePublic('ECHO_generateNavBar')
! 439: def ECHO_generateNavBar(self):
! 440: """Erzeuge Navigationsbar"""
! 441: link=""
! 442: object="self"
! 443: ret=[]
! 444: path=self.getPhysicalPath()
! 445: for element in path:
! 446:
! 447:
! 448: if not element=="":
! 449: object+="."+element
! 450:
! 451: label=eval(object).label
! 452: link+="/"+element
! 453: if not label=="":
! 454: ret.append((label,link))
! 455: return ret
! 456:
! 457: security.declarePublic('ECHO_rerenderLinksMD')
! 458: def ECHO_rerenderLinksMD(self):
! 459: """Rerender all Links"""
! 460: #print "HI"
! 461: #return "OK"
! 462: for entry in self.__dict__.keys():
! 463: object=getattr(self,entry)
! 464:
! 465:
! 466: try:
! 467:
! 468: if object.meta_type == 'ECHO_resource':
! 469:
! 470: object.ECHO_getResourceMD(template="no")
! 471:
! 472: except:
! 473: """nothing"""
! 474:
! 475: return "Rerenderd all links to resources in: "+self.title
! 476:
! 477:
! 478:
! 479: security.declarePublic('printall')
! 480: def printall(self):
! 481: return self.scientific_information.__dict__.keys()
! 482:
! 483:
! 484: def getCoords(self):
! 485: try:
! 486:
! 487: x= [string.join(x,",") for x in self.coords]
! 488: return x
! 489:
! 490: except:
! 491:
! 492: return []
! 493:
! 494: def __init__(self,id,title,label,description,content_type,responsible,credits,weight,sortfield,coords):
! 495: #print "CO",coords
! 496:
! 497: self.id = id
! 498: """Festlegen der ID"""
! 499: self.credits=toList(credits)
! 500: self.label = label
! 501: self.title=title
! 502: self.description=description
! 503: self.content_type=content_type
! 504: self.responsible=responsible
! 505:
! 506: self.weight=weight
! 507: self.sortfield=sortfield
! 508: coordsnew=[ string.split(x,",") for x in coords]
! 509: self.coords=coordsnew
! 510:
! 511:
! 512: manage_options = Folder.manage_options+(
! 513: {'label':'Main Config','action':'ECHO_Collection_config'},
! 514: {'label':'Rerender Links','action':'ECHO_rerenderLinksMD'},
! 515: {'label':'Graphics','action':'ECHO_graphicEntry'},
! 516:
! 517: )
! 518:
! 519: def ECHO_graphicEntry(self):
! 520: """DO nothing"""
! 521: if 'overview' in self.aq_parent.__dict__.keys():
! 522: pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self)
! 523: return pt()
! 524: else:
! 525: return "NO OVERVIEW GRAPHICS"
! 526:
! 527: def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None):
! 528: """Enter coords"""
! 529: coords=self.coords
! 530: temco=coordstr.split(",")
! 531: temco.append(angle)
! 532: coords.append(temco)
! 533: self.coords=coords[0:]
! 534: #pt=PageTemplateFile('Products/ECHO_content/ECHO_draw.zpt').__of__(self)
! 535: if RESPONSE is not None:
! 536: RESPONSE.redirect('ECHO_graphicEntry')
! 537:
! 538:
! 539: security.declarePublic('ECHO_Collection_config')
! 540: def ECHO_Collection_config(self):
! 541: """Main configuration"""
! 542:
! 543: if not hasattr(self,'weight'):
! 544: self.weight=""
! 545:
! 546: if not hasattr(self,'sortfield'):
! 547: self.sortfield="weight"
! 548: #print "HI"
! 549: if not hasattr(self,'coords'):
! 550: self.coords=[]
! 551:
! 552: pt=PageTemplateFile('Products/ECHO_content/ChangeECHO_Collection.zpt').__of__(self)
! 553: return pt()
! 554:
! 555:
! 556: security.declarePublic('changeECHO_Collection')
! 557:
! 558:
! 559: def changeECHO_Collection(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,sortfield="weight",coords="",RESPONSE=None):
! 560:
! 561:
! 562: """Änderung der Properties"""
! 563: #print "HI",coords
! 564: coordsnew=[ string.split(x,",") for x in coords]
! 565: #print "HO",coordsnew
! 566: setECHO_CollectionInformation(self,context,science,practice,source_type,period,id,title,label,description,content_type,responsible,credits,weight,coordsnew)
! 567:
! 568: self.sortfield=sortfield
! 569:
! 570: if RESPONSE is not None:
! 571: RESPONSE.redirect('manage_main')
! 572:
! 573: security.declarePublic('index_html')
! 574:
! 575: showOverview=DTMLFile('ECHO_content_overview',globals())
! 576:
! 577:
! 578: def index_html(self):
! 579: """standard page"""
! 580: #print self.objectIDs()
! 581:
! 582: if 'index.html' in self.__dict__.keys():
! 583: return getattr(self,'index.html')()
! 584: elif 'overview' in self.__dict__.keys():
! 585: #print "HI"
! 586: return self.showOverview()
! 587:
! 588:
! 589: pt=PageTemplateFile('Products/ECHO_content/ECHO_content_standard.zpt').__of__(self)
! 590: pt.content_type="text/html"
! 591: return pt()
! 592:
! 593: def getCredits(self):
! 594: """Ausgabe der credits"""
! 595: if self.credits:
! 596: return self.credits
! 597: else:
! 598: return []
! 599:
! 600: def getGraphicCoords(self):
! 601: """Give list of coordinates"""
! 602: subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource']
! 603: ids=[]
! 604: for entry in self.__dict__.keys():
! 605: object=getattr(self,entry)
! 606: #print "OB:",object
! 607:
! 608: try:
! 609: #print "MT:",object.meta_type
! 610: if object.meta_type in subColTypes:
! 611: #print "MT:",object.meta_type,object.getId()
! 612: for coordtemp in object.coords:
! 613: if len(coordtemp)>3:
! 614: coord=coordtemp[0:4]
! 615: if hasattr(object,'title'):
! 616: if not object.title=="":
! 617: ids.append([string.join(coord,", "),object.getId(),object.title])
! 618: else:
! 619: ids.append([string.join(coord,", "),object.getId(),object.getId()])
! 620: else:
! 621: ids.append([string.join(coord,", "),object.getId(),object.getId()])
! 622:
! 623: except:
! 624: """nothing"""
! 625: #print "IDS",ids
! 626: return ids
! 627:
! 628: def getSubCols(self,sortfield="weight"):
! 629:
! 630: subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource']
! 631: ids=[]
! 632: for entry in self.__dict__.keys():
! 633: object=getattr(self,entry)
! 634: #print "OB:",object
! 635:
! 636: try:
! 637: #print "MT:",object.meta_type
! 638: if object.meta_type in subColTypes:
! 639: ids.append(object)
! 640:
! 641: except:
! 642: """nothing"""
! 643: try:
! 644: sortfield=self.sortfield
! 645: except:
! 646: """nothing"""
! 647:
! 648: tmplist=[]
! 649: for x in ids:
! 650: if hasattr(x,sortfield):
! 651: try:
! 652: x=int(x)
! 653: except:
! 654: """nothing"""
! 655: tmp=getattr(x,sortfield)
! 656: else:
! 657: tmp=10000000
! 658: tmplist.append((tmp,x))
! 659: tmplist.sort()
! 660: return [x for (key,x) in tmplist]
! 661:
! 662:
! 663:
! 664:
! 665:
! 666:
! 667: def manage_AddECHO_collectionForm(self):
! 668: """Nothing yet"""
! 669: pt=PageTemplateFile('Products/ECHO_content/AddECHO_collectionForm.zpt').__of__(self)
! 670: return pt()
! 671:
! 672:
! 673: 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):
! 674:
! 675: """nothing yet"""
! 676: scientificClassificationObj=scientificClassification(context,science,practice)
! 677:
! 678: scientificInformationObj=scientificInformation(source_type,period)
! 679:
! 680:
! 681: newObj=ECHO_collection(id,title,label,description,content_type,responsible,credits,weight,sortfield,coords)
! 682:
! 683: self._setObject(id,newObj)
! 684: getattr(self,id)._setObject('scientific_Information',scientificInformationObj)
! 685: getattr(self,id).scientific_Information._setObject('scientific_Classification',scientificClassificationObj)
! 686: if RESPONSE is not None:
! 687: RESPONSE.redirect('manage_main')
! 688:
! 689: class ECHO_root(Folder,Persistent,Implicit):
! 690: """ECHO Root Folder"""
! 691: meta_type="ECHO_root"
! 692:
! 693: def __init__(self,id,title):
! 694: """init"""
! 695: self.id = id
! 696: self.title=title
! 697:
! 698: def getPartners(self):
! 699: """Get list of Partners. Presently only from a subfolder partners"""
! 700: partnerTypes=['ECHO_partner']
! 701: ids=[]
! 702: for entry in self.partners.__dict__.keys():
! 703: object=getattr(self.partners,entry)
! 704:
! 705: try:
! 706:
! 707: if object.meta_type in partnerTypes:
! 708: ids.append(object)
! 709:
! 710: except:
! 711: """nothing"""
! 712:
! 713: return ids
! 714:
! 715: def getCollectionTree(self):
! 716: """get the collection tree (list of triples (parent,child, depth)"""
! 717:
! 718: def getCollection(object,depth=0):
! 719: depth+=1
! 720: collections=[]
! 721: for entry in object.__dict__.keys():
! 722: element=getattr(object,entry)
! 723: try:
! 724: if element.meta_type=="ECHO_collection":
! 725: collections.append((object,element,depth))
! 726: collections+=getCollection(element,depth)
! 727: except:
! 728: """nothing"""
! 729: return collections
! 730:
! 731:
! 732: return getCollection(self)
! 733:
! 734: def getCollectionTreeIds(self):
! 735: """Show the IDs of the Tree"""
! 736: ret=[]
! 737: for collection in self.getCollectionTree():
! 738: ret.append((collection[0].getId(),collection[1].getId(),collection[2]))
! 739: return ret
! 740:
! 741:
! 742:
! 743: def manage_AddECHO_root(self,id,title,RESPONSE=None):
! 744: """Add an ECHO_root"""
! 745: self._setObject(id,ECHO_root(id,title))
! 746:
! 747: if RESPONSE is not None:
! 748: RESPONSE.redirect('manage_main')
! 749:
! 750: def manage_AddECHO_rootForm(self):
! 751: """Nothing yet"""
! 752: pt=PageTemplateFile('Products/ECHO_content/AddECHO_root.zpt').__of__(self)
! 753: return pt()
! 754:
! 755: class ECHO_partner(Image,Persistent):
! 756: """ECHO Partner"""
! 757:
! 758: meta_type="ECHO_partner"
! 759:
! 760: def __init__(self, id, title,url, file, content_type='', precondition=''):
! 761: self.__name__=id
! 762: self.title=title
! 763: self.url=url
! 764: self.precondition=precondition
! 765:
! 766: data, size = self._read_data(file)
! 767: content_type=self._get_content_type(file, data, id, content_type)
! 768: self.update_data(data, content_type, size)
! 769:
! 770: manage_options = Image.manage_options+(
! 771: {'label':'Partner Information','action':'ECHO_partner_config'},
! 772: )
! 773:
! 774: def changeECHO_partner(self,url,RESPONSE=None):
! 775: """Change main information"""
! 776: self.url=url
! 777: if RESPONSE is not None:
! 778: RESPONSE.redirect('manage_main')
! 779:
! 780:
! 781:
! 782: def ECHO_partner_config(self):
! 783: """Main configuration"""
! 784: if not hasattr(self,'url'):
! 785: self.url=""
! 786: pt=PageTemplateFile('Products/ECHO_content/ChangeECHO_partner.zpt').__of__(self)
! 787: return pt()
! 788:
! 789:
! 790: manage_AddECHO_partnerForm=DTMLFile('ECHO_partnerAdd',globals(),
! 791: Kind='ECHO_partner',kind='ECHO_partner')
! 792:
! 793:
! 794:
! 795: def manage_AddECHO_partner(self, id, file,url, title='', precondition='', content_type='',
! 796: REQUEST=None):
! 797: """
! 798: Add a new ECHO_partner object.
! 799:
! 800: Creates a new ECHO_partner object 'id' with the contents of 'file'.
! 801: Based on Image.manage_addImage
! 802: """
! 803:
! 804: id=str(id)
! 805: title=str(title)
! 806: content_type=str(content_type)
! 807: precondition=str(precondition)
! 808:
! 809: id, title = OFS.Image.cookId(id, title, file)
! 810:
! 811: self=self.this()
! 812:
! 813: # First, we create the image without data:
! 814: self._setObject(id, ECHO_partner(id,title,url,'',content_type, precondition))
! 815:
! 816: # Now we "upload" the data. By doing this in two steps, we
! 817: # can use a database trick to make the upload more efficient.
! 818: if file:
! 819: self._getOb(id).manage_upload(file)
! 820: if content_type:
! 821: self._getOb(id).content_type=content_type
! 822:
! 823: if REQUEST is not None:
! 824: try: url=self.DestinationURL()
! 825: except: url=REQUEST['URL1']
! 826: REQUEST.RESPONSE.redirect('%s/manage_main' % url)
! 827: return id
! 828:
! 829:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>