File:  [Repository] / ECHO_content / ECHO_collection.py
Revision 1.7: download - view: text, annotated - select for diffs - revision graph
Thu Jan 8 17:01:35 2004 UTC (20 years, 5 months ago) by dwinter
Branches: MAIN
CVS tags: HEAD

made coords option

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

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