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