File:  [Repository] / ECHO_content / ECHO_collection.py
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Wed Dec 10 10:53:55 2003 UTC (20 years, 6 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD


bug fixed: koordinaten eingabe in main config

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>